On Sat, Mar 24, 2012 at 1:44 AM, Cedric Greevey <cgree...@gmail.com> wrote: > 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
I think the word "reader" above applies both to the human and computer kinds. You've only addressed the problem for the computer. A user would still have to look at the end of the collection to know if it is a set or map (or use editor). > 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. Sorry to break it to you, but # is used in many places other than lambdas, so even if you remove it from #{} you still have foo#, #^foo, #^{foo bar}, #'foo, #"foo", #_foo, #foo{1 2}, #foo[1 2], and others I've probably forgotten. One option you have is to use Emacs to replace #{} and #() with something distinctive looking. (dolist (mode '(clojure-mode slime-repl-mode)) (eval-after-load mode `(font-lock-add-keywords ',mode (mapcar (lambda (pair) `(,(car pair) (0 (progn (compose-region (match-beginning 1) (match-end 1) ,(cadr pair)) nil)))) `(("\\(#\\){" "∈") ("\\(#\\)(""ƒ") ("(\\(fn\\)[\[[:space:]]" "λ") ("(\\(comp\\)[\[[:space:]]" "∘") ("(\\(range\\)[\[[:space:]]" "ℝ") ("(\\(apply \+\\)[\[[:space:]]" "∑") ("(\\(Math/pi\\)[\[[:space:]]" "π") ("(\\(->\\)[\[[:space:]]" "→") ("(\\(partial\\)[\[[:space:]]" "þ") ("(\\(complement\\)[\[[:space:]]" "¬") ;; not working ;; ("Math/pi[:space:]" "π") ;; ("(\\(apply \+\\)[\[[:space:]]" "∑") ))))) Cheers, Scott -- 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