in reply to bless + tie

This rather defeats the point of OO arch. Presumbably you want to do this:

$obj->{attibute} # instead of $obj->get_attribute();

Which given that most object are just blessed hashes you can do right now.....

package Foo; use Data::Dumper; my $o = new Bar; print $o->get_attribute(), $/; print $o->set_attribute('new val'), $/; print $o->set_flubber('dubber'), $/; print "Direct access, interpolated get flubber = $o->{flubber}\n"; print $o->no_exist(); print Dumper $o; package Bar; sub new{ return bless { attribute => 'value' }, shift } sub AUTOLOAD { my $self = shift; my ( $func ) = $AUTOLOAD =~ m/::([^:]+)$/; if ( $func =~ s/^set_// ) { return $self->{$func} = shift; } elsif ( $func =~ s/^get_// ) { return exists $self->{$func} ? $self->{$func} : undef; } else { my @caller = caller(); warn "Non existant function $func() called by:\n@caller\n"; return 0; } } sub DESTROY{}

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
You missed my point
by cbraga (Pilgrim) on Oct 01, 2003 at 06:13 UTC
    I wanted to get rid of getter/setter methods (even those generated by autoload) replacing them with hash access, while preserving object integrity by intercepting the hash accesses and possibly processing them in a tied hash fashion...

      My point would be what on earth for. Just so you can do this:

      print "Blah $obj->{attribute} blah\n"; # instead of print "Blah ", $obj->get_attribute(), " blah\n";

      Seems to me all you achieve is to obfuscate your code, make it less maintainable, and slow it down.....

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

        The original notes:
        (to) interpolate them inside a string

        Not much of a reason, but there it is.

        It also could be used to speed up an application by developing with his simple data objects and then switching to plain old hashes live.