FYI, in the process of trying to eliminate bindingScope from
DynamicScope, I discovered that all bindings are specific to the scope
they're in. I had thought there was a single binding scope for the whole
frame, but that's not the case. Witness!
b = binding; eval 'x = 1', b; eval 'puts x'
# => ok, same binding
b = binding; proc {eval 'x = 1'}.call; proc {eval 'puts x'}.call
# => error...the evals each are using bindings specific to the procs
b = binding; proc {eval 'x = 1', b}.call; eval 'puts x'
# => ok...we're specifying a specific binding for the first eval
proc {b = binding; eval 'x = 1', b}.call
proc {b = binding; eval 'puts x', b}.call
# => error...different binding in each scope
So the summary here is this:
1. Each scope can have its own binding scope, which acts like a child scope
2. All binding-related calls in a given scope use the same binding
scope. Multiple calls to Kernel#binding produce new Binding objects, but
they point at the same binding scope. eval calls not given a binding
implicitly use that same scope.
3. eval can be specified to run under another scope's binding scope. If
you specify a Proc as the binding for eval, it basically just uses the
binding scope in that scope.
And the bottom line is that DynamicScope *does* need to have a
bindingScope field, since each scope created can have its own binding scope.
No action items for y'all...just posting this FYI.
- Charlie
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email