At 11:42 AM +1000 5/11/02, Damian Conway wrote: >Aaron Sherman asked: > >> > > 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? > >Not quite. C<$.bar> is a direct access to the attribute. C<.bar> is a call >to the accessor. There might well be performance issues. > >> ".bar" is the auto-created accessor for >> "$.bar", so they should do the same thing, no? > >Presumably, but perhaps not quite as fast.
Right. I expect the method-style accessor to be slightly slower in most cases. It may perhaps be optimized away in some cases, but I wouldn't expect it, generally speaking. -- Dan --------------------------------------"it's like this"------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk