I'm trying to understand how the two forms here differ:
In a fresh repl:
user=> '((a) (b) (c))
((a) (b) (c))
which is OK, those are just symbols.
But then:
user=> (defn x [] (a) (b) (c))
java.lang.Exception: Unable to resolve symbol: a in this context
(NO_SOURCE_FILE:2)
so defn is doing something more than quoting the symbols (which quote
did without generating an exception), but less than eval/execution.
http://clojure.org/evaluation says:
A Symbol is resolved:
...
• Else, it is not qualified and the first of the following applies:
...
• If in a local scope (i.e. in a function definition), a lookup is
done to see if it names a local binding (e.g. a function argument or
let-bound name). If so, the value is the value of the local binding.
• A lookup is done in the current namespace to see if there is a
mapping from the symbol to a var. If so, the value is the value of the
binding of the var referred-to by the symbol.
...
searching for 'local scope' using clojure.org's search box hasn't been
fruitful.
I did read through http://clojure.org/special_forms since the text
quoted above mentioned function definitions, but I didn't find
anything there either.
I'd like to understand how this works, as I am writing a DSL and I
want to be able to invoke the symbol resolution (to catch typos, etc)
without having to be in a defn or let context.
Thanks,
-Doug
--
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
To unsubscribe, reply using "remove me" as the subject.