http://clojure.org/data_structures defines how the various data structures
implement IFn.
I would expect either http://clojure.org/vars
or http://clojure.org/Evaluation to talk about the chaining of vars, but if
either does I'm missing it.
On Monday, 27 May 2013 01:04:42 UTC+1, JvJ wrote:
>
>
I suppose that would depend on the specifications for how various objects
are cast to functions. For instance, vectors, maps, sets, keywords, etc.
have their own specific ways of acting as functions. Do you know where
that is specified?
On Sunday, 26 May 2013 18:35:55 UTC-4, Simon Katz wrote:
Additionally, we can make the chain into a loop.
(defn f1 [] 42)
(def f2 #'f1)
(def f3 #'f2)
(def f1 #'f3)
(f3) ==> stack overflow
On Sunday, 26 May 2013 18:18:57 UTC-4, JvJ wrote:
>
> Actually, I spoke WAY too soon.
>
> It looks like it has to do with the way that Var is cast to IFn.
>
>
> http
Cool; thanks. That's an implementation-level explanation, which is fine as
far as it goes.
Can anyone point at a specification-level explanation?
On Sunday, 26 May 2013 23:18:57 UTC+1, JvJ wrote:
>
> Actually, I spoke WAY too soon.
>
> It looks like it has to do with the way that Var is cast to
Actually, I spoke WAY too soon.
It looks like it has to do with the way that Var is cast to IFn.
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java
Check out lines 391 and 410. When invoked, the result of fn() is invoked.
fn() casts deref() (the data contained by the
I could be wrong, but I believe that symbols and vars are separate
entities.
f1 is a symbol which is associated with a var that contains the function.
When you evaluate the symbol 'f1, it looks at the association to find the
var.
It looks like, when you define f2 and f3 to take on those var