From: Daniel Brockman Date: 2005-07-23T00:31:56+09:00 Subject: Re: ruby gnome question Hal Fulton writes: > Joe Van Dyk wrote: > >> What the. Is that the principle of Matz's least surprise >> coming up again? Cuz it sure didn't meet JVD's principle >> of least surprise. > > Congratulations, you get to retrain your neural net. :) > > There are good reasons for the distinction here. > Frequently (I might dare to say: most often) you want to > pass the same args on to the parent's method. You frequently need to do this to other methods as well. So I think it would have been both more useful and less confusing to invent a piece of syntax for passing along the same arguments to another method. Something like this: def foo(bar, baz, *rest, &block) super(...) # Do additional stuff. end def bar(baz, quux, *rest, &block) @moomin.bar(...).postprocess end I'm not trying to stir up trouble; I just wanted to let Joe know he's not the first person whose PLS this doesn't meet. > But sometimes you need more control. In fact, there is no > guarantee that the two methods will even have the > same arity. > > So you get to pass whatever you want. If what you pass is > "nothing" then this is a special case -- you have to > surround the "nothing" with parentheses: super() And that looks really strange if you're not familiar with this language quirk. One of the most basic facts you learn about the Ruby syntax is that ‘foo()’ equals ‘foo’. -- Daniel Brockman So really, we all have to ask ourselves: Am I waiting for RMS to do this? --TTN.