[Phoenix-pm] inside out objects
Scott Walters
scott at illogics.org
Wed Nov 23 09:31:40 PST 2005
Yes, thanks for the fix... I was copying and modifying code and not
testing it. Oops.
-scott
On 0, Brock <awwaiid at thelackthereof.org> wrote:
> On 2005.11.23.17.06, Scott Walters wrote:
> |...
> | This is the AUTOLOAD glue needed to so that objects created as
> | follows work:
> |
> | package Person;
> | use hashclosure;
> |
> | our $this;
> |
> | sub new {
> | my $class = shift;
> | my $name;
> | my $age;
> | bless {
> | name => sub { $name },
> | set_name => sub { $name = shift },
> | age => sub { $age },
> | set_age => sub { $age = shift },
> | print_stats => sub {
> | my $self = shift;
> | print "name: ", $self->name, "\n";
> | print "age: ", $self->age, "\n";
> | },
> | get_older => sub {
> | my $self = shift;
> | $self->age++;
> | },
> | }, $class;
> | }
> |
> |...
>
> Should that print_stats sub be
>
> print_stats => sub {
> print "name: $name\n";
> print "age: $age\n";
> $this->other_method_invocation();
> }
>
> without the need to get $self? Also with that example self-method
> invocation?
>
> --Brock
>
> _______________________________________________
> Phoenix-pm mailing list
> Phoenix-pm at pm.org
> http://mail.pm.org/mailman/listinfo/phoenix-pm
More information about the Phoenix-pm
mailing list