John Williams writes:
> On Tue, 20 Apr 2004, Luke Palmer wrote:
> > There. Now here's the important part: in order to *use* all this, you
> > import whatever module defines it, and then say:
> >
> > class Dog {
> > method foo (?$arg) is accessor {
> > # accessor code here
> > }
> > }
> >
> > If that's not easy enough for you, well, you're probably out of luck.
>
> It would be even easier if we could put the read-accessor-code and
> write-accessor-code in different methods.
>
> class Dog {
> multi method foo { ... }
> multi method foo ($arg) is accessor { ... }
> }
Ugh! That's what I originally suggested, and it was shot down it was.
My first solution to your problem introduced the traits C<get> and
C<set>, allowing you to write it like this:
class Dog {
method foo ()
will get { ... }
will set { ... }
{ } # usually empty
}
I guess I bogged down that message with the implementation, so the
result may have been easy to miss.
Luke