From: ptkwt@... (Phil Tomson) Date: 2004-09-14T12:40:18+09:00 Subject: Re: traits & roles In article <44679.129.94.6.30.1095124491.squirrel@webmail.imagineis.com>, Gavin Sinclair wrote: >Phil wrote: >>> module Foo1 >>> def foo; "foo1"; end >>> end >>> >>> module Foo2 >>> def foo; "foo2"; end >>> end >>> >>> class X >>> end >>> >>> x = X.new >>> >>> x.foo # error >>> >>> x.extend Foo1 >>> x.foo # "foo1" >>> >>> x.extend Foo2 >>> x.foo # "foo2" >>> >>> x.unextend Foo2 >>> x.foo # "foo1" >>> >> >> Yes, you're right. This would be better behavior. Any idea how >> something like that could be implemented? > >Yep: in the Ruby core! :) > Yeah, I'm afraid you're probably right (at least to do it 'nicely') >Only pure-Ruby solution I can think of is to remember the modules that >have been mixed in, and selectively reapply earlier ones when 'unextend' >is called. Pretty fugly. > Perhaps, but it's probably possible. Is there an 'extended' callback? if not 'extend' could be redefined. Phil