On Tue, 2004-04-20 at 10:13, John Siracusa wrote:
> On 4/19/04 7:20 PM, Larry Wall wrote:
> > On Mon, Apr 19, 2004 at 06:53:29PM -0400, John Siracusa wrote:
> > : Yeah, that's exactly what I don't want to type over and over :)
> >
> > I really don't understand what you're getting at here. First you
> > complain that you'd rather write an ordinary method, and then you
> > complain that you have to. Have I met someone lazier than me? :-)
>
> Possibly :) Here's what I'm saying. In the first version of a class, there
> will probably be a lot of simple get/set attributes. It's convenient not to
> have to write any explicit methods for those.
>
> If I accept the default accessors that you get "for free" when a class "has
> $.foo is rw", then that means the users of my class can do $obj.foo =
> whatever in order to set the foo attribute.
And if you override the accessor, you can:
multi method foo(Str $blah = undef) is rw($new) {
(my($old),$.foo)=($.foo,$blah//$new);
.update_the_world_in_some_cool_way();
return $old
}
and while that's verbose, it's only a bit more verbose than:
multi method foo(Str $blah) {
(my($old),$.foo)=($.foo,$blah);
return $old;
}
which is what you would have write ANYWAY to add your new functionality.
--
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback