ara.t.howard / noaa.gov wrote:
> heh.  i think you may be hitting the same thing i was.  here's some food for
> thought:
>
>
> this works:
>
>      harp:~ > cat a.rb
>      class C
>        include Module.new{ def m() 'a' end }
>        include Module.new{ def m() super + 'b' end }
>        include Module.new{ def m() super + 'c' end }
>      end
>
>      p C.new.m
>
>
>      harp:~ > ruby a.rb
>      "abc"
>
>
> while this does not:
>
>      harp:~ > cat a.rb
>      class C
>        def m() '' end
>
>        include Module.new{ def m() super + 'a' end }
>        include Module.new{ def m() super + 'b' end }
>        include Module.new{ def m() super + 'c' end }
>      end
>
>      p C.new.m
>
>
>      harp:~ > ruby a.rb
>      ""
>
> even more distilled:
>
>      harp:~ > cat a.rb
>      class C
>        def m() '' end
>
>        include Module.new{ def m() 'a' end }
>      end
>
>      p C.new.m
>
>
>      harp:~ > ruby a.rb
>      ""
>
>
> i find that behviour quite suprising... in fact, it seems like a bug, but i'm
> probably wrong...  thoughts?

Not at all becasue inclusion adds to the inheritance chain, it doesn't
inject methods. You can of course define an #inject method if you like.
But it's still difficult to do the orginial intent of this thread b/c
of how #super works.

Personally I think it would cool if you could redefine a method calling
on the previous definition just as one can redefine a variable calling
on it's previous definition. Eg.

  a = 1
  a = a + 1

  def a ; 1 ; end
  def a ; a + 1 ; end

This would eliminate the need for #super except in cases of recursion,
in which case a special notation is also needed for the definition. Eg.
def_rec a, or something. But that's cool b/c it would be safer.

In anycase, alternate solutions to the alias issue include
#wrap_method, #alias_chain, Matz' :before and :after system (semi-aop)
and cuts (aop).

T.