On Sat, Mar 15, 2003 at 11:27:03AM +0000, Nicholas Clark wrote: : I think that it would be nice to be able to chain yourself in there, rather : than having to replace. : : In perl5 there are some things you have to override, rather than adding to. : Offhand I can't see a practical way that the opcode loop or the regexp engine : could be done in any other way, but IIRC require is hookable, and : UNIVERSAL::AUTOLOAD and the core ops have to be replaced, when what you might : like to do is just wrap to extend things. Or will wrapping these routines be : good enough?
Maybe. For dispatch-related subs, it will depend heavily on how the run-time system optimizes dispatches. No way are we going through that entire list on every dispatch without some kind of caching of the result so that we can dispatch more directly next time. (Perl 5 already does this with regular method dispatches.) But if we depend on wrapping, and if wrapping becomes a common occurrence at run time, and if we have to recalcuate our dispatches every time someone wraps a routine, then we're gonna be hosed on the performance front. : Sort of related - if you wrap a subroutine, and then something else wraps : the subroutine (and hence wraps you), can you pull your wrapper off without : everything getting confused? (ie their wrapper now directly wraps the : original) Yes, that's why you .unwrap using the id that .wrap returned. : ie if Acme::Foo wraps &DISPATCH, then Acme::Bar is loaded at it wraps : &DISPATCH, then the script removes Acme::Foo, is the wrapping now as if : only Acme::Bar was the only module ever loaded? Well, the way you've said it makes it sound like the wrapper is going to be pointing at a module Acme::Foo that isn't there anymore. I assume by "removes Acme::Foo" you really mean "removes the wrapper installed by Acme::Foo". Certainly if you call the .wrap and .unwrap methods properly, everything should stay in sync. We've not generally been in the habit of catering to people who remove modules, but if we did want to support that, we'd probably have some kind of destructor for the module that could unwrap things wrapped by the module. Larry