This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-27
Channels
- # aleph (1)
- # beginners (48)
- # cider (34)
- # clojure (27)
- # clojure-dev (15)
- # clojure-uk (21)
- # clojurescript (27)
- # data-science (3)
- # datomic (10)
- # instaparse (30)
- # lumo (85)
- # off-topic (3)
- # perun (2)
- # portkey (24)
- # re-frame (13)
- # reagent (17)
- # ring (1)
- # shadow-cljs (77)
- # spacemacs (1)
- # test-check (3)
- # yada (4)
(defn get-fn-reference
[kw]
(let [kns (namespace kw)
snm (symbol (name kw))]
(some-> kns
symbol
find-ns
(ns-resolve snm)
deref)))
(defmacro x
[body]
`~(get-fn-reference body))
(= (x clojure.core/not=)
(get-fn-reference 'clojure.core/not=))
Repeating from #clojure. I'm confused as to why x
returns a new instance of the not=
function class each time.@dominicm that's really strange, and appears to me to be some sort of equality problem
check this out
user=> (x clojure.core/not=) #object[clojure.core$not_EQ_ 0x158a3b2e "clojure.core$not_EQ_@158a3b2e"] user=> (get-fn-reference 'clojure.core/not=) #object[clojure.core$not_EQ_ 0x158a3b2e "clojure.core$not_EQ_@158a3b2e"]
stupid formatting, but they appear to be the same object, with the same pointer.
This is my fault for only doing the equality test after minimising my repro:
(defmacro x
[body]
(let [a# (get-fn-reference body)]
`(quote ~a#)))
Does have a different pointer @tbaldridge. This was my original example.what is happenig is that the macro is causing a literal function value to be evaluated
when you do it as a single form at the repl, it runs in interpreter mode and the interpreter evaluation of a function object is the object itself
and the compilation of a function object is the instantiation of a new instance of its class