Hello All:
Noticed the following works in Clojure 1.6 and 1.7 (didn't test prior to
that):
user=> ('+ 'a 'b)
b
Also "works" for any set of symbols:
user=> ('abra 'ka 'dabra)
dabra
My expectation was that using symbols or keywords in the function/operator
position would throw an exception similar to this:
user=> (3 4)
ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn
user/eval7668
(form-init2947310628177413729.clj:1)
I noticed Keywords can also be used in the operator position:
user=> (:abra :ka :dabra)
:dabra
And mixing and matching is OK:
user=> (:a 'b 3)
3
It seems to act something like an implicit `do` in that it returns the last
value but, in fact, not quite as you seem to need to have more than two
items:
user=> ('do)
ArityException Wrong number of args (0) passed to: Symbol
clojure.lang.AFn.throwArity (AFn.java:429)
user=> ('do (+ 1 2 3))
nil
user=> ('do 'this (+ 1 2 3))
6
But more than 3 is not accepted:
user=> ('do 'this 'please 3)
ArityException Wrong number of args (3) passed to: Symbol
clojure.lang.AFn.throwArity (AFn.java:429)
user=> ('do 'this 'please 'now 'ok?)
ArityException Wrong number of args (4) passed to: Symbol
clojure.lang.AFn.throwArity (AFn.java:429)
A quick search didn't reveal any bug reports or previous discussions on
this but I may have missed something (feel free to point me in the right
direction).
Is it just a "quirk" or is it useful in some way? Intended behavior or bug?
Cheers,
Michael O'Keefe
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.