In Clojure REPL:
('+ 1 2) ; 2
('+ 1 2 3) ; (err) clojure.lang.ArityException: Wrong number of args (3) passed to: clojure.lang.Symbol
Why it happens and how it works? I tried to inspect the code, but I can't figure out what is calling in function position
Clojure symbols are functions too and are implemented like get
. So what you are calling here is (get 1 '+ 2)
, which is OK (tries to look up '+
in 1
, which can not work and therefor returns the fallback of 2
). And the arity just does not work; only 1-2 arguments allowed.