From: TRANS Date: 2006-09-09T06:58:11+09:00 Subject: Re: better alias_method On 9/8/06, Sylvain Joyeux wrote: > > 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. > I don't see how you write "recursive methods which call super". Like is Haskell you'd have to explictily state it's recursive. So for instance I'm suggesting: class A def x; "x"; end end class B < A def x; x.upcase; end end Ordinarily B#x would recurse (and be an infinite loop). But not so in my suggestion. So the above would work and rather you'd have to tell it esspecially if recursion were desired, something like: class A def x(n); n - 1 ; end end class B < A def_rec x(n) x == 1 ? 1 : n + x(x(n)) # err... x(super(n)) end end Now in this case how do you call A#x from B#x if you need to? We would still need to have #super as shown in the comment. Hmm... better yet, you could do without super altogther and also not need the special def_rec if we had a special method that meant "this method", maybe #this. So: class B < A def x(n) x == 1 ? 1 : n + this(x(n)) end end Would work for the recursive case. T.