in reply to Re: Maintaining State with Runtime Traits
in thread Maintaining State with Runtime Traits

Don't know why my reply didn't show up. I'll try again.

The ISA cache isn't invalidated (that I'm aware of) because when applying the trait to a class, ISA isn't affected. The methods get compiled directly into the class. As for applying a trait to an instance, I follow the Perl 6 route and make a new anonymous class. That alters ISA and if I layer on several runtime traits it might be a problem, but for the most part, it's not caused me any difficulty.

Cheers,
Ovid

New address of my CGI Course.

  • Comment on Re^2: Maintaining State with Runtime Traits

Replies are listed 'Best First'.
Re^3: Maintaining State with Runtime Traits
by diotalevi (Canon) on Oct 14, 2006 at 00:13 UTC

    Compiling a new method also clears the cache but that doesn't really matter since I expect there's a limited number of classes that this is happening to and it's not a "runtime" thing. Its when you go clearing your cache at runtime that you get perl's OO to start losing that 30-40% performance vs functions that we used to hear so much about. I've understood that it's all the having to do ISA method lookups that made perl OO slow and applying this stuff to objects during rumtime is buying that problem back again.

    But then elegant solutions are also very nice for a programmer and that might be more expensive yet than the CPU time.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊