in reply to Generic object in inside-out classes

That's an interesting technique -- I'm definitely adding it to my notes for the next time I give my inside-out objects talk.

One negative that I see is that it adds even more overhead to every property access -- instead of id being an alias to refaddr, this approach has a second function call and a comparison.

That means I'd never want to implement this unless it was really necessary. I certainly wouldn't use it for convenience to specify initializing values -- that's a high runtime cost for a one-time activity.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^2: Generic object in inside-out classes
by Anno (Deacon) on Feb 11, 2007 at 13:57 UTC
    Scalar::Util could provide an id() function (say) with the variant behavior implemented in XS. That would reduce the overhead to nil.

    Alternatively, perl 5.10 will have Hash::Util::FieldHash to support inside-out classes. A class based on that will allow generic objects.

    Anno