Re: RFC for $ME class variable (was Re: RFC 124 (v1) Sort order for any hash)
[email protected] ((Randal L. Schwartz))
| Newsgroups | perl.perl6.language.objects |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "John" == John Siracusa <[email protected]> writes: John> I don't like $ME either, but my alternative is probably even more John> blasphemous: use $self. "It usurps a variable name that has been legal for John> customer use in prior Perls!" you re-exclaim. Not if it only appears in a John> new-to-Perl-6 construct like: John> method get_polite_age(<neat stuff could go here>) John> { John> return ($self->age >= 40) ? 39 : $self->age; John> } Well, that I could support. Although having the p52p6 translator recognize which subs should really be methods might be a bit messy, and then it'd have to recognize any uses of $self for a proper $self, and not shift something into that, or whatever. :) <voice character="Dr. Smith">The pain! The pain!</voice> John> But wait, it gets worse: I'd even be happy with the bareword "self" John> method get_polite_age(<neat stuff could go here>) John> { John> return (self->age >= 40) ? 39 : self->age; John> } John> I know, I'm obviously crazy as a loon. You may escort me to Perl culture John> prison now... ;) I'll have an adjacent cell. I actually like that *better* than $self. Let's not stop there though. Perhaps we need "self" and "super" and "thisContext". Only half joking... this would solve a lot of the hacking issues. self could be a "die" if we weren't called as a method, and then we wouldn't need to have a separate "method" type. Oooh. Getting better all the time! Or maybe just return undef, and let the method call fail on the undef, or we could check it ahead: if (my $me = self) { $me->do_this } else { $CGI::Q->do_this } To steal from CGI.pm's problem. Or, if it threw an exception: try { self->do_this } error { $CGI::Q->do_this } or whatever the syntax is this week. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[email protected]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!