From: "T. Onoma" Date: 2003-11-27T15:45:46+09:00 Subject: Re: Method wrapping On Thursday 27 November 2003 12:32 am, Yukihiro Matsumoto wrote: > responsibility to define Ruby2 behavior: > |1. Is it possible to add multiple wrappers for a method or > |not? Do they "stack"? > > They stack. > > |2. If they do stack, is it possible to redefine a method as we > |are used to doing? Or will that simply add a new wrapper? > > Re-defining primary method (method without :pre, :post, or :wrap) > replaces old primary methods. I would like to point out that their is some inconsistentcy in this behavior, in that def behaves differently depending on whether it is defined in class augmentation or a subclass. class A < X def riot super print "P" end end class A def riot # this redifines super print "R" end end class B < A def riot super # this wraps print "W" end end The def syntax is the same but each has different semantic meaning (effects code readability/code maintainence). It is important to understand that Ruby already has a wrapping facility using subclasses. And singletons act similiarly. So it would be more consistent to naturally extend that to in-class wraps. We can do this without having to add special syntax sugar (the colon). Furthermore, from what I can tell, the current proposal does not address super wrapping. An issue have delt with in my AOP work. Please refer to: http://www.rubygarden.org/ruby?AspectOrientedRuby for more information on all this. -t0