On 04/08/2013 08:35 AM, David Cantrell wrote:
On Fri, Apr 05, 2013 at 09:20:16PM -0400, Jerrad Pierce wrote:

Regardless, my understanding was that although perl's sub calls are
somewhat expensive ...

I think it's *method calls* that are expensive, not subroutine calls.
The reason being that the subroutine that a method resolves to can
change at runtime.


not exactly. subs in perl (and all dynamic langs) are expensive due to
the amount pushed on the stack and such. method calls can be slower due
to the lookup but the method name and code ref can be cached for speed
so it isn't that much slower if you call the method multiple times (as
you would in deep recursion). the
sub call itself is the much larger part of the overhead.

from perlobj:

If a missing method is found in a base class, it is cached
in the current class for efficiency. Changing @ISA or defining new
subroutines invalidates the cache and causes Perl to do the lookup
again.


also recursion can be done in OO style too. Template::Simple does that
so it can pass down any OO values set for the parsing of the template.

uri


_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to