Does anyone know what's going on here?

user=> (let [a 1] (eval 'a))
1
user=> (ns another-ns)
nil
another-ns=> (let [a 1] (eval 'a))
CompilerException java.lang.RuntimeException: Unable to resolve symbol: a 
in this context, compiling:(NO_SOURCE_PATH:41) 

If let-bound locals were treated as symbols in "user", this behavior would 
be understandable (though I don't know why on earth "let" would be 
implemented in such a bizarre fashion). Anyways, locals are *not* symbols 
in "user", as you can see:

user=> (let [a 1] user/a)
CompilerException java.lang.RuntimeException: No such var: user/a, 
compiling:(NO_SOURCE_PATH:1) 

I started tracing through the code for (eval) in Compiler.java, but got 
lost at the point where it wraps (let) forms in (fn [] ...) before 
evaluating them...

BTW, if you convert the above "let" to an equivalent lambda expression, the 
behavior is consistent between "user" and other namespaces:

user=> ((fn [a] (eval 'a)) 1)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: a 
in this context, compiling:(NO_SOURCE_PATH:6) 

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

Reply via email to