hey

i have a question:
if i do this in the top level:
> foo = lambda {p a}
> eval "a=1"
> foo.call

It doesn't work, giving me a NameError: undefined variable or method in
main:Object

but whats perhaps wierder, is if i do this:
> foo = lambda {p b}
> eval "b=1", foo
> foo.call

it gives the same error, but
> p b
now works. that is, b is bound in the global scope

now my understanding is:
1) the first version should bind 'a' in the global scope (it does), and
foo should now be able to access it (it cant)
2) the second version should bind 'b' in the context of foo's binding
therefore making it local to foo, so foo should still be able to access
b, but it should not be visible in the top level.. yet the opposite
behaviour is observed

how come?? what am i missing here?

thnx

-- 
Posted via http://www.ruby-forum.com/.