in reply to The need to rebless (was: Informal Poll: Traits)
in thread Informal Poll: why aren't you using traits?

When you have a generic proxy object like Object::Realize::Later, which more or less implements lazyness for method calls, it is quite convenient to have the object change class after it has been realized. Otherwise, lots of (brain-dead, I admit) checks fail when they ask UNIVERSAL::isa($obj,'foo');. Of course one could circumvent this problem with multiple inheritance or by writing a specialized ::Proxy class for every class to be lazy ...

  • Comment on Re^8: Informal Poll: Traits (Long Post Warning!)

Replies are listed 'Best First'.
Re^9: Informal Poll: Traits (Long Post Warning!)
by chromatic (Archbishop) on Nov 21, 2005 at 08:07 UTC

    Override isa() in your code and tell anyone who calls it as a function that their code breaks yours, 'cuz it does.

Re^9: Informal Poll: Traits (Long Post Warning!)
by dragonchild (Archbishop) on Apr 18, 2006 at 12:21 UTC
    Class::LazyLoad doesn't need to do this. I wonder why you felt that Object::Realize::Later needed to do so.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

      From a look at the documentation, Class::LazyLoad doesn't seem to support classes that implement cheap operations but can become the full fledged object on demand. Which is what Object::Realize::Later does. There are ways around this that don't need reblessing into the full class I guess, like aggregation/creation of a new instance, but reblessing is the easy/safe way. This is discussed in the Traps section of the documentation.

        This is true. C::LL supports non-existence or existence. Apparently, O::R::L supports the intermediate state. Neat!

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?