in reply to bless + tie

Getter and setter methods suck.

Who write getter and setter methods in Perl? Oh right, those guys from languages with less flexible OO models...

sub property { my $self=shift; if (@_) { $self->{property}=shift; return $self; } else { return $self->{property}; } }

Even if they're autogenerated, they still suck because we can't interpolate them inside a string.

print "Property: @{[$obj->property]}\n";

Course it is one char more than using stright concatenation.

If you do go the tie overload route (not _such_ a bizarre course, but one I think ultimately youll reject as a Neat Idea But....), then you should carefully read the example code at the bottom of the overload documentation. It contains a full implementation of a two face tie. The trick is that for it to work you need to keep your underlying object representation at least one step away from the one you plan to expose. For instance your object could be a reference to a reference to a hash. Then you could overload the hash dereference or array dereference as you choose. Of course this will slow your program down and it will introduce nasty horrible bugs in various versions of perl that will make the tricks dangerous enough that I doubt its worth your while. *shrug*.

In case its not clear, I'm _fully_ with tachyon on this one.


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi