Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: private recursive subroutines

by demerphq (Chancellor)
on May 13, 2007 at 17:19 UTC ( [id://615187]=note: print w/replies, xml ) Need Help??


in reply to Re^3: private recursive subroutines
in thread private recursive subroutines

Thanks, this is pretty much the response I would have made. The only thing I'd add is that as far as I understand things Perl 5.10 wont pay the same global penalty, rather the penalty will be restricted to the package or method itself, although I'm not sure which. This a side effect of Brandon Black's MRO patch for adding C3 style method resolution support to Perl.

---
$world=~s/war/peace/g

Replies are listed 'Best First'.
Re^5: private recursive subroutines
by ph713 (Pilgrim) on May 14, 2007 at 00:14 UTC
    Yes, in perl-current with my mro.c stuff (and eventually 5.10), when you change the @ISA of a class or change a method in a class, it only invalidates the method cache of that specific class, as well as any classes which inherit from that class (as opposed to the behavior in 5.9.4 and earlier, where changing a method or @ISA anywhere invalidated all method caches globally).

    Also, while in 5.9.4 and earlier the recursive lookup via @ISA is performed every time an uncached method call was made, with the new mro stuff the recursive @ISA parent hierarchy of a class is linearized into a simple flat list of classes to search with no duplicates, and cached. That "linearized isa" cache is only blown on @ISA changes in the given class or its parents, not method changes. So even when you (locally) invalidate the method caches by redefining a subroutine, these @ISA linearizations stay in place, making that first lookup to refill the cache faster than it was before.

      Im just curious as to whether there will be any way from perl code to see the linearized array. I could see that being useful indeed. Maybe @^ISA could provide read access to this data.

      ---
      $world=~s/war/peace/g

        Yes, via mro::get_linear_isa('Foo'). This and other related calls are docced in bleadperl's "perldoc mro". There's also MRO::Compat on CPAN, so you can start using those interfaces today and be forward/backward compat between 5.6/5.8/5.10.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://615187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-19 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found