On Sat, Mar 24, 2012 at 04:44, 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}}
>
> without breaking anything. It's not possible for it to be a valid map
> literal, because the outer {...} pair has only one object inside it
> and a map literal requires an even number of objects (zero, two, four
> ...), so right now {{foo bar baz}} will just throw a
> CompilerException, and so will {{foo bar baz quux}} even though the
> inner {...} pair then has an even number of objects. Making the reader
> treat that as a set literal is therefore a purely additive change.
>
> It's one character longer than #{foo bar baz} but it looks nicer, IMO,
> and still shows the cousin-ship between sets and maps by using the
> same choice among {}, [], ().

I'd encourage you to have a look at LispReader.java [1], paying
particular attention to how macros[] and dispatchMacros[] are used
internally. Basically, the reader dispatches to a specialized
sub-reader based on the first character of what it reads. This gives
the reader a nice modularity while also allowing the reader to convert
a characters to data in a single pass. This has real advantages, but
arbitrary syntax tricks like {{ foo bar }} don't fit well into this
world.

[1] 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java

I guess what I'm saying is that there is a deeper mechanism behind
what may seem to you like arbitrary syntactic noise. #{...} #(...)
etc.  Your proposal is unlikely to garner much support if you're not
able to formulate an argument that appreciates the complexity
trade-offs it implies. (Say, a far more complex Reader.)

One of the nice things about Lisps is that their written
representation as data is uncomplicated to parse. Don't be too quick
to throw that away.

// Ben

-- 
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

Reply via email to