On 6/15/06, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov> wrote: > > here's my complaint against any non-module based solution: it wildly violates > POLS due to the change in scoping. i'm not saying it can't be done, but read > over these tests/demos carefully and you'll see it's not quite as > straightforward as you're suggesting - espcially if you want 'normal' class > method definition semantics. > > i think you may be able to work around some of these issues, but some are part > of ruby. > [snip persuasive code examples] You ~could~ get round the constant scoping problem with: module N meta_module{ self::C = true const_get :C } end which is similar to the way we deal with locals shadowing attributes (and just as likely to catch us out). Also, using: mod.instance_variable_set(:@meta_module, @meta_module.clone) seems to avoid the double inclusion and namespace pollution problems. I can't see a way to avoid the 'stack level too deep' in recursive inclusion though. However, as I said earlier, I think your implementation is the most straightforward (though I also think that having the InstanceMethods module in there is obscuring your argument in the present discussion). Regards, Sean