Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

chromatic
  (email not shown publicly)
http://wgz.org/chromatic/

Blog Information [technorati.com] Profile for chr0matic [technorati.com]

Journal of chromatic (983)

Wednesday April 02, 2008
06:00 PM

A New Alternative to Monkeypatching

[ #36036 ]

I thought I’d share a technique that I’ve known about for some time, but seems to not have gotten into the normal ruby vernacular.

This trick is the use of super in methods contained in a Module.

Evan Phoenix, super is your friend

This post was a day late, right?

Update: added the rest of the punchline sentence.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • That's not very nice, cutting out the rest of the sentence like that. Here it is for your faithful readers:

    This trick is the use of super in methods contained in a Module.

    His point being that most Ruby users don't think to use super in a module, since OO literature tends to condition you to think of it in the context of classes only. I've no idea if super is legal in a Java interface, for example.

    When folks start blogging about techniques with super and traits as if it's something special, I'll be sure

    • Except you won’t, because Perl 6 has multiple inheritance, so for correctness it will have to be “next”, not “super”… which is something we already [cpan.org] do [cpan.org] in Perl 5 (and for the same reason). So it’s going to be business as usual in v6.

    • His point being that most Ruby users don't think to use super in a module...

      Why would they think to use methods in a module then?

      OO literature tends to condition you to think of it in the context of classes only.

      That's irrelevant. Plenty of OO literature tends to condition people to think of polymorphism in terms of inheritance only. Plenty of OO literature is bad. Besides, little extant OO literature recommends monkeypatching (or my favorite euphemism for monkeypatching, punching grandma up the