Re: Is the binding (in closure) dynamic or static?
Hi Kim,
> g = { |y| return x+y }
> f = { |x| return g(1) } // Will x be binded in the closure g ?
> assert f(17) == 18 // For the dynamic binding, this should be passed.
x in closure g refers to a variable that either exists only in the body
of g or that is visible in the same scope as g and f. The x in closure
f exists only in f and hides any outer x for the body of f. Therefore,
if this sample was run as a script, assert f(17) == 18 should get you a
compile error, a runtime error, or false, depending on how the language
actually handles undefined variables (the x in closure g is not
defined). As to what the implementation currently does . . . I don't
have a build handy, so you'll have to check for yourself.
Later,
Chris.