I'm trying to determine if there is a way to gain access to the
dynamic and lexical bindings tables at both run-time and compile-
time.  In general this seems like a bad idea, but I'd like to be able
to modify the evaluation environment while performing compile-time
partial evaluation.  Last night I played around with clojure.lang.Var/
find and clojure.lang.Namespace.getMappings which appeared to let me
access the dynamic scope.  I went further, digging into the .java code
and found the static field clojure.lang.Compiler/LOCAL_ENV, which if
accessed during macro expansion time contains the lexical bindings.  I
know from experimenting that an exception is thrown if you attempt to
evaluate a lexical variable during compilation time (makes sense):

(let [x 5] (clojure.contrib.macros/const x))

doesn't work (which makes sense since 5 could be anything).

So, is there a way to access the dynamic and lexical bindings
directly, at compile time or run time?  If not, are there any
shortcuts around implementing my own tables and performing
substitution?

-- Tim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to