From: Peter Date: 2003-12-01T21:20:35+09:00 Subject: Re: Underpinnings of Method Wrapping > Sorry, source of confusion: I used 'wrap' here to mean a combined pre and > post. (Mentally, I'm still repeating def for an intrinsic wraps). Perhaps > better terms are: inner wrap and outer wrap? So with the above I was pointing > out that we could just have a separate keyword for outer wrap definitions. I know. Inner wrap and outer wrap are fine BTW. > You're a man after my own heart! :-) I don't know if you noticed the research > notes at the bottom of the RCR, but this is essentially one of the notations > I was playing with and very much liked. Perfect for outer wraps. And pdef > actually works pretty well too, once you think about it for a sec. Short and > to the point. :-) (And yeah, I noticed :-) > That would be great, I have some other work to do too. So afterward, I take it > you want to collaborate on a finalized joint RCR on the matter? That would be > excellent. And yes, some good examples are quite important. I'd love to collaborate on it. (Funny how I tumbled into this just by defending Matz's proposal.) > I think so. Could you clearify these two different syntaxes and where they > apply, so that I can be sure that I'm understanding you correctly? I kept it deliberately vague because I think we still need to make a final decision on the syntax. But if we use your syntax, wrapping would look like this: class X def y print "X" end end c = X.new def c.y print "(" super print ")" end def c.y print "[" super print "]" end c.y # [(X)] And the old behavior would look like this: class X def y print "X" end end c = X.new redef c.y print "(" super print ")" end redef c.y print "[" super print "]" end c.y # [X] But then we'd need to make clear that conceptually c gets its own, new singleton class at creation, and the redefs are in that class. Also the first redef could have been a def... BTW, singleton classes are equal to their superclasses currently, so a singleton class isn't really visible except for the extra methods (unless I'm overlooking something). class X def y print "X" end end a = X.new b = X.new c = X.new def b.y print "(" super print ")" end def c.y print "[" super print "]" end a.y # => X b.y # => (X) c.y # => [X] a.class # => X b.class # => X c.class # => X a.instance_of? X # => true b.instance_of? X # => true c.instance_of? X # => true a.class == b.class && b.class == c.class # => true a.class.superclass # => Object b.class.superclass # => Object c.class.superclass # => Object Peter