in reply to Maintaining State with Runtime Traits

Interesting. Your Trait::Selected class looks very much like an inside-out class. In fact, using Object::InsideOut it could be implemented, very simply, as follows:
package Trait::Selected; use Object::InsideOut; my %is_selected :Field :Acc(is_selected);
(Of course, looking at Class::Trait, I see that it offers a lot of functionality beyond that covered by my simple example above.)
Class::Trait->apply( $some_class, 'Trait::Selected' );
Ah, sweet synergy! This prompted me to add a runtime inheritance mechanism to Object::InsideOut:
My::Class->add_class('Trait::Selected');
What happens when the object goes out of scope? The trait still retains that object’s selected value and it’s tricky to remove.
If done using Object::InsideOut, this is no issue at all: The trait will be automatically cleaned up when an object is destroyed.

I just uploaded Object::InsideOut v2.08 (which contains the runtime inheritance feature) to CPAN. Thanks for the idea.


Remember: There's always one more bug.

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

    Bink! That piques my interest. Can't wait to see it out there and I'll start playing with it. Maybe that's enough to get me over the learning curve hurdle. Thanks!

    Cheers,
    Ovid

    New address of my CGI Course.