in reply to Re^2: How is redefining a sub internally done?
in thread How is redefining a sub internally done?

Inherited subs are cached into the namespace that inherits them.

# Causes something akin to # `*Foo::method = \&Base::method;` $foo->method();

But it uses a counter system to invalidate the cache. The package's counter is incremented when the package is changed, making it so the counter in the cached entry no longer matches the package's, invalidating the cached entry.

Perhaps that same mechanism is used here.

Replies are listed 'Best First'.
Re^4: How is redefining a sub internally done?
by LanX (Saint) on Sep 30, 2024 at 13:12 UTC
    Well maybe

    I tried to look into the code of pp_entersub but didn't understand much... 🤷🏻‍♂️

    Personally when trying to implement this, I would try to use the original sub to link to the current one. Hence just a hop away.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery