On Sat, Mar 24, 2012 at 1:28 AM, Sean Corfield <seancorfi...@gmail.com> wrote: > On Fri, Mar 23, 2012 at 8:44 PM, Cedric Greevey <cgree...@gmail.com> wrote: >> #{foo bar baz} is somewhat ugly. It occurs to me that one could modify >> the reader to additionally accept >> >> {{foo bar baz}} > > My concern is that {{1 2 3 4}5} is currently legal - a map with a map > as a key and 5 as the value. That means that the reader couldn't tell > if {{ introduced your set notation or the start of a nested map > without looking arbitrarily far ahead. And that problem gets worse if > you encounter {{{ or {{{{ or... {{{ could introduce a nested map, a > map of your sets or one of your sets containing a map...
The other objections are fair enough -- matters of taste. But the above is a technical problem with a simple fix: make one pass over the source, converting it into a rudimentary AST whose nodes just look like (thing thing thing), #(thing thing thing), [thing thing thing], {thing thing thing}, and #{thing thing thing} (the file as a whole can be regarded as implicitly wrapped in (do ... )); then (assuming no unbalanced delimiters) make a second pass doing the rest of the reader's job. The second pass will see a {...} node with one direct child that is also a {...} node in, and only in, the case of the proposed set syntax. (It will also allow { {foo bar baz}} and similarly as sets.) As for the aesthetics, what I like about {{...}} is that the delimiters are symmetrical, unlike #{...}, and it would allow one to reserve use of the # mark to, mostly, closures, so # would stand out more as typically indicating a lambda. (The #{...} syntax then remains comparatively desirable in the specific case that the set literal is being used as a predicate, as it's both a set and a lambda in that context.) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en