3 ms·
If you want late binding at the call site it's probably unavoidable to have some extra complexity anyways, what if I changed f into something that wasn't callab
by poizan42 10y ago
If you want late binding at the call site it's probably unavoidable to have some extra complexity anyways, what if I changed f into something that wasn't callable?
However Clojure binds at the definition time, e.g.
> (defn f [] 42)
#'sandbox9516/f
> (f)
42
> (def g f)
#'sandbox9516/g
> (g)
42
> (def f 1337)
#'sandbox9516/f
> (g)
42
> (f)
java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
- jeremiep 10y agoThat's because defn binds f to the _value_ of the function, while (f) binds to the _variable_. > (defn f [] (f)) #'sandbox9672/f > (def g f) #'sandbox9672/g > (def f 42) #'sandbox9672/f > (g) java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
- deleted 10y ago[deleted]