in reply to Single accessor/mutator idiom in Perl5, Perl6 and Python
It makes the accessor/mutator more flexible at the expense of a little overhead. If you're worried about the overhead, you should probably access the hash keys directly ;-)sub foo { my $self = shift; my $old = $self->{'foo'}; $self->{'foo'} = shift if @_; $old; } #foo
And of course, many of these accessor/mutator methods are created automatically when they are needed using some AUTOLOAD magic.
Liz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: Single accessor/mutator idiom in Perl5, Perl6 and Python
by merlyn (Sage) on Aug 17, 2003 at 16:27 UTC | |
|
Re: Re: Single accessor/mutator idiom in Perl5, Perl6 and Python
by demerphq (Chancellor) on Aug 17, 2003 at 10:55 UTC | |
by liz (Monsignor) on Aug 17, 2003 at 11:13 UTC | |
|
Re^2: Single accessor/mutator idiom in Perl5, Perl6 and Python
by adrianh (Chancellor) on Aug 17, 2003 at 15:57 UTC |