Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change root binding of Vars #332

Open
1 task
jfacorro opened this issue Jul 11, 2017 · 0 comments
Open
1 task

Change root binding of Vars #332

jfacorro opened this issue Jul 11, 2017 · 0 comments

Comments

@jfacorro
Copy link
Member

jfacorro commented Jul 11, 2017

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:

  1. Redefine with def : would mean the whole module is re-compiled, which is somewhat expensive in some cases.
  2. Store root bindings in ETS: introducing another indirection will make accessing the root binding slower for all Vars.
  3. 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.
  4. Don't support changing root binding of vars.

Related tests:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant