From: Charles Oliver Nutter Date: 2009-02-25T16:32:26+09:00 Subject: [ruby-core:22456] Re: YASNP (Yet Another Selector Namespace Proposal) Ondrej Bilka wrote: > On Wed, Feb 25, 2009 at 01:12:03AM +0100, Charles Oliver Nutter wrote: >> Here's a new mock-up of this behavior in JRuby (without making parser >> modifications that would certainly clean it up more): >> >> {{ >> module Foo >> module Bar >> def to_s >> puts 'inside namespace: ' + to_s >> 'blah' >> end >> end >> end >> >> using Foo::Bar => String >> >> puts 'hello'.to_s >> puts 1.to_s >> >> #output: >> >> inside namespace: hello > This code should output inside namespace: inside namespace: inside namespace: inside namespace: inside namespace: inside namespace: ... The namespace applies from that point forward; the original Foo::Bar module is unaffected. This could be modified to be for a full file, but it would require more parser help and ideally would have to be at the top of the file. - Charlie