On 9/10/07, ara.t.howard <ara.t.howard / gmail.com> wrote:
>
> On Sep 10, 2007, at 4:32 PM, Logan Capaldo wrote:
>
> > Care to give an example?
>
> sure.
>
> file: traits.rb
> ...
> 8 class Object
> 9 #--{{{
> 10   def singleton_method_added(*a, &b)
> 11 #--{{{
> 12     ret = super rescue nil
> 13     obj = self
> 14     obj.__trait_singleton_class.__trait_module_eval
> { @__trait_singleton_super = obj }
> 15     ret
> 16 #--}}}
> 17   end
> ...

I assume __trait_singleton_class is (class << obj; self; end) and
__trait_module_module is a wrapper around module_eval?

You can do this without ivars, just define a __trait_singleton_super
singleton method that returns obj, Or you can do it with ivars but
keep the ivar in the object instead of the singleton class.

>
> this object is used in the search path: traits implements attr like
> methods with inheritance.
>
>
> a @ http://drawohara.com/
> --
> we can deny everything, except that we have the possibility of being
> better. simply reflect on that.
> h.h. the 14th dalai lama
>
>
>
>
>