You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some functions/macros that rely on being able to change the root binding of Vars (e.g. with-redefs-fn). In Clojerl the root binding for a Var is returned by a function with a __val suffix, the compiler makes sure the root binding is always a literal. When the Var is a function the root binding is the Var itself, and also a function with the same name is generated (e.g. #'clojure.core/inc is backed by the functions inc__val/0, which returns #'clojure.core/inc itelf, and inc/1).
Alternatives:
Redefine with def : would mean the whole module is re-compiled, which is somewhat expensive in some cases.
Store root bindings in ETS: introducing another indirection will make accessing the root binding slower for all Vars.
Dynamic binding approach: it wouldn't actually be changing the root binding, but the value returned by non-dynamic Vars could be changed on a process basis.
There are some functions/macros that rely on being able to change the root binding of Vars (e.g.
with-redefs-fn
). In Clojerl the root binding for aVar
is returned by a function with a__val
suffix, the compiler makes sure the root binding is always a literal. When theVar
is a function the root binding is theVar
itself, and also a function with the same name is generated (e.g.#'clojure.core/inc
is backed by the functionsinc__val/0
, which returns#'clojure.core/inc
itelf, andinc/1
).Alternatives:
def
: would mean the whole module is re-compiled, which is somewhat expensive in some cases.ETS
: introducing another indirection will make accessing the root binding slower for all Vars.Var
s could be changed on a process basis.Related tests:
The text was updated successfully, but these errors were encountered: