http://qs1969.pair.com?node_id=624276


in reply to RFC: Alter - Perl extension for Alter Ego Objects

I'm glad it makes its way to CPAN. It is IMHO the best, cleanest and most flexible implementation of objects in perl, them being inside-out adding another point.

I believe it will give birth to a new way of doing OO in perl, since Alter objects are truely polymorphic by nature. You can tell them to behave like this or that, merely by blessing them into the package which is needed at the time. (Of course, for multiple ego extensions, those packages must be Alter-aware.)

Keep up the great work, Anno!

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
  • Comment on Re: RFC: Alter - Perl extension for Alter Ego Objects

Replies are listed 'Best First'.
Re^2: RFC: Alter - Perl extension for Alter Ego Objects
by Anno (Deacon) on Jul 01, 2007 at 21:15 UTC
    Thank you. One thing. You said about Alter-based objects

    You can tell them to behave like this or that, merely by blessing them into the package which is needed at the time.

    Re-blessing isn't really involved in accessing alter egos. It's the package the call to ego() is compiled into that determines the class whose ego is seen. That will normaly be the right one when a class compiles its accessors.

    Anno

      It is really common for interesting objects to compile their own accessors. If you require that and break on things compiled in the "wrong" class, much of CPAN is in a world of hurt if applied to your code.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

        I don't understand.

        An object from a given class (which doesn't know about alter egos) will continue to access the object body (if that's what it does) with no interference. If an Alter-based class initializes and uses that object, a corona of alter egos will be attached for the Alter-based class(es) to use. The original class will know nothing about that and continue doing what it did all along.

        Where's the problem?

        Anno

        Update: I'm not trying to make old code use the alter technique, that's the next stage :)