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

Re: RFC 152 (v1) Replace $self in @_ with self() builtin (not $ME)

From:
Nathan Wiger
Date:
August 24, 2000 13:27
Subject:
Re: RFC 152 (v1) Replace $self in @_ with self() builtin (not $ME)
Message ID:
39A58515.842A9C21@west.sun.com
Tom Christiansen wrote:
> 
> It is?  I don't see that this is a pain at all.  It seems like
> a beautiful point of homogenization.  You don't force the user
> to say $self; they could use $this if they wanted.  Heck, they
> don't need it at all.
> 
>     my(undef, @args) = @_;

It's a pain if you want to support both function-oriented and
object-oriented calling forms, as CGI.pm does. For example, you can use
both of these:

   print header;
   print $r->header;

with CGI.pm. Now you need a self_of_default special method, since
sometimes $_[0] has a class ref and sometimes it has the first method
argument.

> Or as in
> 
>     shift->fn(@_)

I don't see how this RFC is super-revolutionary, personally. Your
example would just become:

   self->fn(@_);

with the added benefit that, unlike shift->fn(@_), you can call the same
thing 10 times in a row and it still works:

   self->fn1(@_);
   self->fn2(@_);     # can't do that with shift

I also don't see how this precludes the use of $ME, $self, $this, or any
other variable name:

   $ME = self;
   $self = self;
   $this = self;

-Nate



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