Experience building open src projects crowdfunding site in Clojure (from Django)
groups.google.com
groups.google.com
I'm not shocked if I stated some inaccurate things; I'm still very new to the language, and how and even why some things work the way they do is not obvious to me.
So the #() syntax is a reader macro I'm assuming? That would explain a lot. I guess what I enjoyed about them is that they cut down on a lot of boilerplate.
In javascript, passing in an anonymous function, you have to explicitly name the arguments. So you've got something like:
map(function(item) {item + 2}, list))
In Clojure you can gut that down to:
(map #(+ % 2) lst)
This isn't that useful for small code snippets, but if you reuse that variable many times, or use multiple variables such as map-indexed, that %, %2, and so on syntax is really friendly. But I could see why there would be limitations. You can't nest them, for one.
You probably are well-aware of these things, but my explanation might make some sense to those who haven't used the language.
Right. However, #((+ % 2)) would be the same idea for functions instead of expressions, and would then have allowed you to use that syntax to build and return a vector.
You can still build a vector, but you now have to realize that [] is a reader macro for (vector), so you can do #(vector 1 %) instead of #([1 %]).
However, if there was really great anonymous function syntax (maybe {} declaring a function with no arguments), then if wouldn't be a special form: it would be an internal function that took a boolean and two functions.
The result of that change would then trickle through all kinda of other macros (as they could then be implemented as functions instead), and soon you end up with a language that no longer relies on so much non-first-class syntax edits.