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.
I hadn't actually planned on doing anything special--when you wrap a sub, the PMC that represents the sub gets its code pointer replaced with the wrapping sub PMC, which itself holds the wrapped code pointer. Wrap something and generally nobody knows the difference, because the outside interface and address doesn't change.
Unwrapping puts the pointer back again and removes the under-the-hood messing about, once again transparently.
--
Dan
--------------------------------------"it's like this"------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk