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 <B5C42927.1C284%[email protected]>
On 8/19/00 11:50 AM, Randal L. Schwartz wrote:
> I actually don't like the literal $ME.  It usurps a variable name that
> has been legal for customer use in prior Perls.  Why not use something
> more "system-belonging" like %_ or even $_?  In fact, "self" in $_ and
> "args" in @_ has a nice symmetry.  Or we make $_->{self} be self, and
> maybe $_->{context} be the calling context, etc etc?

I don't like $ME either, but my alternative is probably even more
blasphemous: use $self.  "It usurps a variable name that has been legal for
customer use in prior Perls!" you re-exclaim.  Not if it only appears in a
new-to-Perl-6 construct like:

method get_polite_age(<neat stuff could go here>)
{
  return ($self->age >= 40) ? 39 : $self->age;
}

No one's ever written a Perl "method" before Perl 6, only Perl 4 and 5
"sub"routines, so no one gets squished.  It's lowercase because it looks
nicer, and because it'll be typed constantly.  Yes, special/magic vars have
traditionally been punctuation-based ($_, $/, $") or all-caps ($ARGV,
$AUTOLOAD).  $self is a new Perl 6 convention: "Implicit variables in
object/class methods are all lowercase and meaningfully named."

But wait, it gets worse:  I'd even be happy with the bareword "self"

method get_polite_age(<neat stuff could go here>)
{
  return (self->age >= 40) ? 39 : self->age;
}

I know, I'm obviously crazy as a loon.  You may escort me to Perl culture
prison now... ;)

-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.