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

[email protected] (John Siracusa)
Newsgroups perl.perl6.language.objects
Message-ID <B5C46782.1C2A6%[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.