develooper Front page | perl.perl6.language.objects | Postings from August 2000

Re: RFC for $ME class variable (was Re: RFC 124 (v1) Sort orderfor any hash)

From:
John Siracusa
Date:
August 19, 2000 13:34
Subject:
Re: RFC for $ME class variable (was Re: RFC 124 (v1) Sort orderfor any hash)
Message ID:
B5C46782.1C2A6%siracusa@mindspring.com
On 8/19/00 4:04 PM, Damian Conway wrote:
> You can have your cake, but not force us to eat it too...

Come, partake of the Loony Cake... :)

> Like $AUTOLOAD, $ME would be dynamically scoped:
> 
> package LoonyBin;
> 
> sub self {$ME};
> 
> sub get_polite_age : method {
> return (self->age >= 40) ? 39 : self->age;
> }

Sure, provided that's standardized via...

> One might even imagine a standard pragma that automatically creates
> such things in any package with methods.

...and, most importantly, cleverly morphed into an efficient implementation
behind the scenes.  We're supposed to be making Perl o-o *more* efficient,
not adding more subroutine calls.  Convenience and performance should
not always have to be mutually exclusive.

> We seem to cope with $AUTOLOAD okay, without the need to:
> 
> sub autoload : lvalue {$AUTOLOAD}
> 
> all the time.

The operative word being "cope" ;)  Also, I tend to write many more methods
than I do autoloaders (YMMV), so I'd almost definitely use an efficient,
convenient, implicit "self" bareword or scalar, whereas I'd probably just
stick with $AUTOLOAD the few times I have to use it.

-John




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About