cljfmt icon indicating copy to clipboard operation
cljfmt copied to clipboard

Support for collapsing multiple metadata expressions

Open arrdem opened this issue 9 years ago • 1 comments

Forms such as ^:foo ^:bar ^:baz qux are legitimate, as are forms which mix multiple reader metadata ala ^{:foo 3 :bar 6} ^:baz ^{:qux 7} zork. However reading such forms is nontrivial because of the left-to-right merge behavior of the reader as well as simple lexical volume.

I propose that the format of two or more nested meta expressions should be by convention the ^{} equivalent, with special exception made for ^foo type tags.

So:

  • ^:a ^:b ... -> ^{:a true :b true} ...
  • ^{:a 3} ^:b ... -> {:a 3 :b true} ...
  • ^:b ^{:a 3} ... -> {:a 3 :b true} ...

But:

  • ^String ^:a foo unchanged
  • ^String ^:a ^:b foo -> ^{:a true :b true} ^String foo
  • ^{:a true :b true :tag String} foo -> ^{:a true :b true} ^String foo

arrdem avatar Jul 27 '16 19:07 arrdem

I don't mind having this as an option, but I don't think it should be the default.

weavejester avatar Jul 27 '16 21:07 weavejester