David Cantrell wrote: > On Mon, Jul 06, 2009 at 05:06:03PM +0100, Nicholas Clark wrote: > >> but Generic::Base::ClassWithTimeout has done something funky to >> wrap &run in a routine that does the eval block/alarm/$SIG{ALARM} >> handler? Basically, the fun is that I'd like to do something >> equivalent to invert the order of inheritance, such that the >> parent's &run seems to be called first, and it can "SUPER" delegate >> to its child. > > You can't use inheritance for this. You need to detect whenever a > class is loaded - perhaps by doing some Voodoo in @INC or %INC. Then > to figure out which classes inherit from your class, use > Class::CanBeA, and then Hook::LexWrap or something similar to wrap > its run() method.
I second that. > It sounds like this would be terribly fragile though. eg, if run() > is AUTOLOADed or otherwise defined at runtime. Good practices dictate that whenever you provide AUTOLOADed methods, you should also override UNIVERSAL::can() to provide proper information about the AUTOLOADable methods. If you have reasonable control over the implementation, I would dare to contradict David and state that fragility is not a big deal. My €0.02 -- Luis Motta Campos is a software engineer, Perl Programmer, foodie and photographer.