It gets even weirder. I tried this hoping it would create a closure like f1
does:
(defn f4 [x] (eval `(let [[x#] ~@[[x]]]
(fn [y#]
(= x# y#)))))
And indeed using no.disassemble in my test cases f1 and f4 always create
the same bytecode: a clojure.lang.AFunction with a field holding the value
x, which is passed through the function's constructor.
Likewise, f2 and f3 always create the same bytecode: an AFunction without
any fields and an empty constructor, with a static constructor creating a
new vector/map/nil.
All the bodies are identical, calling clojure.lang.Util.equiv, with the
argument and the stored reference object.
(now talking about the functions returned by f1-4)
But: in the vector case, f4 takes 140ns, almost twice of what even f2
takes, and much longer than f1 (which is apparently identical!).
It makes no sense that f3 (identical to f2) doesn't take that long.
In the map case, f2, f3 and f4 take the same time, 150ns, again making no
sense as f1=f4.
Is there some metadata I'm missing?
--
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.