This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-10
Channels
- # adventofcode (99)
- # architecture (10)
- # bangalore-clj (1)
- # beginners (65)
- # boot (9)
- # cider (78)
- # clojure (87)
- # clojure-austin (1)
- # clojure-brasil (13)
- # clojure-dev (14)
- # clojure-gamedev (3)
- # clojure-greece (2)
- # clojure-italy (2)
- # clojure-russia (18)
- # clojure-spec (26)
- # clojure-uk (15)
- # clojurescript (62)
- # core-logic (1)
- # cursive (1)
- # datomic (27)
- # emacs (17)
- # fulcro (2)
- # off-topic (44)
- # onyx (25)
- # perun (139)
- # re-frame (40)
- # reitit (2)
- # ring (4)
- # rum (2)
- # shadow-cljs (1)
- # slack-help (14)
- # unrepl (18)
the reason for the "no matching ctor" error, is because you can't evaluate a function object when the function has closed overs locals
the reason why (foo)
works as opposed to throw as it should, is because it happens that the evaluation of a fn is the fn itself unevaluated. (It gets analyzed as a constantexpr and the eval of constantexpr is the input value itself)
user=> (defmacro f [] (doto (constantly 1) println))
#'user/f
user=> (f)
#object[clojure.core$constantly$fn__5404 0x5f7b97da [email protected]]
#object[clojure.core$constantly$fn__5404 0x5f7b97da "[email protected]"]
in the case of function invocation however, it doesn't follow simple evaluation anymore
as the compiler wraps the form in a fn and compiles it, to then invoke the compiled fn
user=> (fn [] (f))
#object[clojure.core$constantly$fn__5404 0xf478a81 [email protected]]
IllegalArgumentException No matching ctor found for class clojure.core$constantly$fn__5404 clojure.lang.Reflector.invokeConstructor (Reflector.java:163)
user=>
and while evaluation the compiler can act as a no-op when trying to evaluate objects, but when compiling it can't