From: Daniel DeLorme Date: 2007-09-12T13:19:51+09:00 Subject: Re: before, after and around Ruby 1.9 Rick DeNatale wrote: > On 9/11/07, Pit Capitain wrote: > >> The module inclusion chain is already dependent on the sequence in >> which the code is executed, especially if you use super. What I like >> about Matz's proposal is that there is still only one of these chains >> and one way to walk them: super. Having a different way to call the >> next method would make things more complicated, IMO. > > Here's the sequence dependency I'm concerned about. > > class A > def m > puts "Hi from A" > end > end > > class B < A > def m > puts "And now a wird from my superclass.!" > super > end > > class B < A > #fix the typo > def m > puts "And now a word from my superclass!" > end > end > > B.new.m > > With the current semantics, this will produce: > > And now a word from my superclass! > Hi from A Actually it will only produce "And now a word from my superclass!" I assume you just forgot the super in there. > whereas Matz' proposal would produce: > > And now a wird from my superclass! > And now a word from my superclass! > Hi from A My understanding of Matz' proposal is that you would need to specify "class B" to get that result. By specifying "class B < A" you would get the same result as current ruby. > How do you REPLACE a method implementation which invokes super in this > brave new world? By defining the method in "regular mode" as opposed to "re-open mode" regular: class A < Object re-open: class A At the risk of repeating myself I really prefer the previous suggestion: regular: class A re-open: class A < A Daniel