On Fri, Feb 27, 2009 at 2:30 PM, Mark Volkmann
<[email protected]> wrote:
>
> On Fri, Feb 27, 2009 at 4:34 AM, Michael Wood <[email protected]> wrote:
[...]
>> Bindings created with binding can be assigned to, which provides a
>> means for nested contexts to communicate with code before it _in_ the call
>> stack.
[...]
>
> The word "before" is what seems out of place to me. The typically use
> of binding that I've seen is for binding a different value to a Var
> for the duration of the binding scope which includes calls that occur
> *after* the binding keyword, but in its scope. For example, println
> normally writes to stdout, but you can changes that for a limited
> scope with binding.
[...]
I actually didn't think too hard about that before your e-mail :) but
I think "before" is right. Jason's example demonstrates what this
means:
user> (def x)
#'user/x
user> (defn foo [] (set! x 10))
#'user/foo
user> (binding [x 1] ; first binding form
[x (binding [x 2] ; second binding form
[x (do (foo) x)]) x])
[1 [2 10] 1]
The second binding form is "before" foo in the call stack, yet foo can
influence it by calling (set! x 10).
I'm not sure if doing this sort of thing is a good idea, though.
While reading the description again I noticed a grammatical error. I
believe it should be:
Bindings created with binding can be assigned to, which provides a
means for a nested context to communicate with code before it in the call
stack.
i.e. "a ... context ... before it" rather than "contexts ... before it"
--
Michael Wood <[email protected]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---