Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: RFC: an unusual inside-out object generator

by Jenda (Abbot)
on Jul 26, 2005 at 14:58 UTC ( [id://478235] : note . print w/replies, xml ) Need Help??

in reply to RFC: an unusual inside-out object generator

Looks kinda nice, how well does it work with inheritance? What happens if a child class defines a property with the same name as the parent one?

I like the Class::OutsideIn name best.

Is there any place this may be downloaded from already? It's hard to discuss something you can't test.

XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented.

  • Comment on Re: RFC: an unusual inside-out object generator

Replies are listed 'Best First'.
Re^2: RFC: an unusual inside-out object generator
by xdg (Monsignor) on Jul 26, 2005 at 16:05 UTC

    Inheritance works very well, for some definitions of "well". The inside-out design is generally very orthogonal -- meaning that it doesn't collide data with superclasses. You can use Object::Local to subclass pretty much any other class, even classes based on some other system -- all it cares about is that the superclass constructor gives back a reference.

    The tricky bit is in the accessors, though. If you define properties with the same name as a superclass, you have to be careful what you wind up with for accessors. By default, Object::Local uses private properties -- no accessors are created as you access the properties directly via the local aliases. (This is sort of the major goal -- strict-safe properties without accessor calls, though you can request accessors, too.) But in that case if the superclass has an accessor with that name, you have to be careful not to call it by mistake when you don't mean to.

    It does not really support multiple inheritance, though, as that generally requires too much coordination within/between object frameworks for setup/teardown. The Object::Local approach treats the superclass as a black-box -- it lets the superclass build a new object, then does its own additional initialization. On destruction, it does its own teardown then has the superclass do its teardown. The design goal is maximum orthogonality.

    If you're really jonesing for a sneak-peak, you can pull from my subversion server. It's a moving target, of course, so some revisions may be buggy, but I usually try not to check in unless all tests are passing. (Occasionally I have to if I'm moving back and forth from the laptop.) Documentation is very sparse so far, so the best way of seeing how it works is to look at the 't/' directory, where the 'Objects' directory contains many simple examples used in testing. I hope to have a release to CPAN by the end of the week -- at this point it's mostly an issue of documentation. The API should change minimally.

    (Edited to change repository target to renamed "Object-LocalVars" directory)


    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.