Cache mechanism for method lookup

F

Ferry Bolhar

Hi,

I've heard that Perl uses a cache when looking up for methods,
so when a method is called again, there is no longer need to
look again into @ISA.

Is this true? If so, how is it implemented? And what will happen
when @ISA gets modified later?

Thanks for your answers & greetings,

Ferry
 
I

it_says_BALLS_on_your forehead

Ferry said:
Hi,

I've heard that Perl uses a cache when looking up for methods,
so when a method is called again, there is no longer need to
look again into @ISA.

Is this true? If so, how is it implemented? And what will happen
when @ISA gets modified later?

Thanks for your answers & greetings,

isn't this what Memoize is for?
 
U

Uri Guttman

isBoyf> isn't this what Memoize is for?

no, they are very different beasts. memoize allows a user sub to cache
its answers and it is has some restrictions such as the sub not doing
any side effects and always returning the same answer for the same
arguments.

perl's guts do cache method lookups as it would be very slow to always
lookup the methods in each namespace listed in @ISA. 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.

uri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top