You can see it at work in this: user=> foo (unable to resolve foo) user=> (when nil (def foo 42)) nil user=> foo (unbound var foo)
When a ‘def’ form is _compiled_ -- which happens in the above case because the whole form must be compiled – then it interns the var. The ‘def’ form is parsed in DefExpr$Parser.parse() and it calls lookupVar(sym, true) – which interns the symbol if it is new (i.e., not yet seen). See various parts of: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood On 6/30/17, 11:28 AM, "Didier" <clojure@googlegroups.com on behalf of didi...@gmail.com> wrote: I admit, this is very surprising. It looks like evaluation happens in two pass, like first it finds all defs and declares them, interning the symbol and creating an unbound var. And on a second pass it evaluates the full form. Can someone more informed confirm or explain in more details what's responsible for this behavior? -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.