http://www.perlmonks.org?node_id=221223


in reply to Re^2: Class::InsideOut - yet another riff on inside out objects.
in thread Class::InsideOut - yet another riff on inside out objects.

You don't want to just look at $Values{$class}, since you need to destroy inherited attributes too.

Isn't that going to be done by that class's DESTROY method? That is, the "next" call will do it.

So the DESTROY method deletes all instances of a particular object in all classes.

I see, that won't wipe out everything, just all the attributes of that object since instance keys are unique.

  • Comment on Re: Re: Re: Class::InsideOut - yet another riff on inside out objects.

Replies are listed 'Best First'.
Re^4: Class::InsideOut - yet another riff on inside out objects.
by adrianh (Chancellor) on Dec 19, 2002 at 19:45 UTC
    Isn't that going to be done by that class's DESTROY method? That is, the "next" call will do it.

    No. The NEXT is there in case we have inherited from another non-inside-out class that has its own DESTROY method.

    The idea is that all of the sub-classes of Class::InsideOut can now avoid writing custom DESTROY methods since the base-class handles it for them.

    Hopefully this makes some vague sort of sense :-)

      Hmm, if the instance held a list of all valid attributes, then you would not need to search all attributes for all classes.

        True, but this list is impossible to determine at compile time since you can change an objects class with bless at any time.

        In theory you could replace bless with a custom version that tracked the object through it's class changes - but this is really just an optimisation - and it's a little early in the day for that :-)