On 2010 Apr 10, at 1:42 AM, Per Vognsen wrote:
On Sat, Apr 10, 2010 at 12:25 PM, Douglas Philips <d...@mac.com>
wrote:
The differences between def and binding are also weird, since
binding does
not also shadow the meta-data on the var, so not only :macro will
be wrong,
but :file, :line, :arglists could also be wrong.
The binding form doesn't provide the semantics of temporary
redefinition.
It provides something which is operationally equivalent, http://clojure.org/vars
says:
Per-thread bindings for one or more Vars can be established via the
macro binding and within-thread they obey a stack discipline:
...
Functions defined with defn are stored in Vars, allowing for the re-
definition of functions in a running program.
Even the official docs call it re-definition.
I don't see why :macro and :arglists need to reside on the var rather
than the function itself and it indeed does lead to some surprises in
odd corner cases. But it is certainly logical and proper that :file
and :line reside on the var.
If I am trying to debug a problem with function foo, and I look at the
meta data for foo to find out where it is defined, I'm going to get
the root binding meta data even if the foo that I am debugging has
actually been rebound with binding? That seems like a bug. It
certainly won't help me figure out where to find the code that is
actually being run when I call foo. So far as I can tell from the
docs, once I'm in the scope of a binding, I cannot even get at the
root binding (or any other binding up the stack).
Anyway, I hope this excursion was enlightening. It forced me to
reinforce my understanding of some of these issues.
Yes, it has been. I realized this morning that Vars are what symbols
used to be.
That def creates Vars from symbols is an easy subtlety to (keep)
forgetting:
http://clojure.org/lisps
* Symbols are not storage locations (see Var)
* All (global) Vars can be dynamically rebound without interfering
with lexical local bindings. No special declarations are necessary to
distinguish between dynamic and lexical bindings. Since Clojure is a
Lisp-1, (global) functions can be dynamically rebound.
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.