On 18 Mar 2010, at 16:55, Per Vognsen wrote:
Is there any reason why a .method occurrence in non-operator position
doesn't just do the closure wrapping automagically?
There is two reasons I can think of, though of course I can't know if
they are the real ones.
First, a technical reason: .method is handled as part of macro
expansion:
user> (macroexpand-1 '(.hashCode 3))
(. 3 hashCode)
The result is a special form for Java interop. Symbols in non-operator
positions are not macro-expanded, so some other mechanism would have
to be invented to handle them in a special way. It would in fact
create a first "special symbol" category, complicating the semantics
of the language, so this is not just a technical reason.
Second, a semantic reason: Java method calls are resolved statically
if possible (you can use reflection warnings to find out where this
fails), making them very fast. Creating and calling a closure is a
much slower operation. Rich has stated at several occasions that he
considers performance in important part of the interface of a
function, so making a clear syntactic distinction between a fast and a
slow operation would fit well with that point of view.
Konrad.
--
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
To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or
reply to this email with the words "REMOVE ME" as the subject.