On Thu, 2002-05-09 at 12:37, David Wheeler wrote: > On 5/8/02 1:24 PM, "Damian Conway" <[EMAIL PROTECTED]> claimed: > > > Yes. > > > > If you write: > > > > class Foo { > > my $.bar; > > my $.baz is public; > > ... > > } > > > > you get a private C<.bar()> accessor and a public C<.baz> accessor. > > 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 } I suppose there could be some magic like: class Foo is accessedby('get_','','r') is accessedby('set_','','rw') { ... } To declare that Foo has accessors with prefix "get_" and no suffix for read-only acces and prefix "set_" and no suffix for read/write access. But, I'm not sure how valuable this would be....