On Fri, 2002-05-10 at 00:27, Damian Conway wrote:
> Aaron Sherman wrote:
> 
> > > What if I want my methods to be called C<.get_bar()> and C<.set_bar()>,
> > > since a certain Perl OO specialist suggests this approach is best for
> > > avoiding ambiguity in one's API?
> > 
> > Then you can declare them as such:
> > 
> >     sub get_bar() { .bar }
> >     sub get_baz() { .baz }
> >     sub set_baz($newbaz) { .baz = $newbaz }
> 
> 
> Close. They'd probably be implemented like this:
> 
>       method get_bar() { $.bar }
>       method get_baz() { $.baz }
>       method set_baz($newbaz) { $.baz = $newbaz }

Wouldn't those be the same? ".bar" is the auto-created accessor for
"$.bar", so they should do the same thing, no?

And in the case of ".baz", I'm assuming that a public member will be
given an "is rw" accessor, so that ".baz = $newbaz" will work the same
as "$.baz = $newbaz".

Granted, I use "sub" instead of "method"... that's going to take some
getting used to, but I suppose it makes sense.


Reply via email to