This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-26
Channels
- # asami (3)
- # babashka (3)
- # beginners (45)
- # boot (3)
- # calva (6)
- # clojure (26)
- # clojure-dev (16)
- # clojure-europe (15)
- # clojure-norway (6)
- # clojure-uk (6)
- # clojurescript (34)
- # community-development (4)
- # conjure (3)
- # datascript (4)
- # datomic (4)
- # emacs (21)
- # events (1)
- # fulcro (16)
- # graalvm (5)
- # jackdaw (1)
- # kaocha (5)
- # lsp (74)
- # malli (8)
- # nbb (37)
- # off-topic (50)
- # pathom (5)
- # reagent (19)
- # ring (1)
- # shadow-cljs (60)
- # sql (3)
hmm I guess there is something in clojure I have never run into before and don't actually understand what is happening
(ns test.thing)
(defrecord Thing []
clojure.lang.IFn
(invoke [this]
"thing"))
(def thing
(Thing.))
(def bar (let [] (thing)))
(def foo (thing))
what is different with (def foo (thing))
that it ends up failing with
Execution error (AbstractMethodError) at test.thing.Thing/applyTo (server.clj:-1).
Method test/thing/Thing.applyTo(Lclojure/lang/ISeq;)Ljava/lang/Object; is abstract
as soon as its used in a top-level def it just fails. (def {:foo (thing)})
or any other collection also fails. wrapping it in a let magically makes it work?
(going from defrecord
to deftype
changes the error message but still complains about applyTo
)
For "simple" code (like invoking a function bound to a var) unless aot compiling, the compiler doesn't bother generating bytecode, it runs a minimal interpreter, which invokes funtions using apply
This might be a weird question, but do you have any tips for me? I'd like to have the depth of understanding of the compiler that you do. Is it as simple as "read all of the compiler source" 😅?
more of the latter then the former, I have a vague idea of the overall structure and what parts exist in the compiler that guides looking for stuff in it, I wouldn't say I have read it all
some familiarity with tools.analyzer output can help a lot, because tools.analyzer does pretty much the same analysis as the compiler does, but the results are nice bits of clojure data.
similarly the clojurescript compiler is a compiler for a clojure like language written in clojure
Thanks so much for the pointers. I haven't spent enough time with tools.analyzer, will start there