I
Intransition
I am confused by the difference between using module_eval on a module,
vs. using eval on a binding extracted from a module.
Have a look at this gist:
http://gist.github.com/445263
When run, it produces:
s2::X uninitialized constant #<S:0x7fa6256160e8>::X
s3::X uninitialized constant #<S:0x7fa625615698>::X
Other than the lack of a local scope (which is not being used), why is
s1 and s2 behaving differently? I would expect the results to be
equivalent. And even more confusing to me, how is it that s3 can see
s2's method definitions even though it's a whole new module!?
Note the 'extend self' doesn't seem to make much of a difference. Take
it out and s1.x is no longer accessible as would be expected. But s2
and s3 seem unaffected.
vs. using eval on a binding extracted from a module.
Have a look at this gist:
http://gist.github.com/445263
When run, it produces:
s2::X uninitialized constant #<S:0x7fa6256160e8>::X
s3::X uninitialized constant #<S:0x7fa625615698>::X
Other than the lack of a local scope (which is not being used), why is
s1 and s2 behaving differently? I would expect the results to be
equivalent. And even more confusing to me, how is it that s3 can see
s2's method definitions even though it's a whole new module!?
Note the 'extend self' doesn't seem to make much of a difference. Take
it out and s1.x is no longer accessible as would be expected. But s2
and s3 seem unaffected.