Using #include at the instance level?

When 'class B < Object' replaced with 'Class.new do' the Ruby 1.8.7 interpreter complains about uninitialized constant N. What is the big reason for dynamically defined class to behave so differently? It would be very non obvious and unexpected behavior. Actually both cases work as expected in Ruby 1.9.1 and this is correct behavior according to the Ruby Draft.

Nice clarification.

Are there two issues here? This issue and the resolution of constants
via instance_eval? Or are these two aspects of the same issue?

I believe they are aspects of the same issue.

In either case, there is no doubt in my mind that 'class B' and 'B =
Class.new do' should work the same.

I agree, but if constant lookup rules are going to be reverted to 1.8 I doubt that both forms will behave the same.

···

--
Fedor Kocherga
http://sidenotes.kocherga.info/

What a tangle.

Seems to me there are two desired behaviors: 1) domain behavior, where
by lookup follows from the point of evaluation, and 2) closure
behavior, whereby lookup follows from the point of definition. Both
are perfectly reasonably and depend solely on the need of the
developer's usecase. There is also the compromise position, first try
domain behavior, failing that try closure behavior.

So if I understand correctly, 1.8 and older used closure behavior, 1.9
switched to domain behavior. There were issues with this change. Some
people suggested the compromise position, but Matz rejected that and
has decided to return to the original closure behavior. Is that a
correct summary?

Short of the compromise position, I would think the only complete
solution would be to allow for both approaches via different methods,
eg. instance_eval vs. instance_domain_eval, or perhaps an option,
instance_eval(&b, :closure=>false).

···

On Dec 30, 10:29 am, Rick DeNatale <rick.denat...@gmail.com> wrote:

On Wed, Dec 30, 2009 at 4:34 AM, Robert Klemme > > <shortcut...@googlemail.com> wrote:
> To sum it up: Ruby 1.9 changed lookup rules from lexical (aka static)
> to dynamic.

That change may not be permanent.

There was a long thread on ruby-core a month or two ago, prompted by a
question raised by Yehuda Katz about the problems the change was
causing for existing DSLs like ActiveRecord and RSpec. After various
proposals to modify the 1.9 behavior to make it more compatible,
Maeda-san posted this:

OSDIR

Matz seems to be in favor of returning to the 1.8 behavior.