in reply to Maintaining State with Runtime Traits

With all this applying of runtime traits are you noticing that your ISA cache is nearly always invalid or what? When you apply a trait to an object does it make a class or what?

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

  • Comment on Re: Maintaining State with Runtime Traits

Replies are listed 'Best First'.
Re^2: Maintaining State with Runtime Traits
by Ovid (Cardinal) on Oct 11, 2006 at 18:04 UTC

    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.

      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.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊