On Thu, Apr 11, 2002 at 08:04:56AM +1000, Damian Conway wrote:
> 
> Reflecting on this, it seems that it would be useful if methods
> implicitly did their default topicalization-of-invocant like so:
> 
>       -> $self
> 
> rather than just:
> 
>       -> $_
> 
> That is, that as well as aliasing the invocant to $_, they also alias it
> to some standard variable name.
> 
> Then one would be guaranteed an invariant name (across all OO Perl!)
> for the invocant, even under internal topicalizations.

Hmmmm... this being the case, is there any reason we should ever need to
name the invocant explicitly? If Perl has already provided a named alias
implicitly, why specify redundant information when other parameters
follow? Leave the parameter lists for parameters that change from method
to method, not for the one that will always be there.

You get short parameter lists, and a truly invariant name for the
invocant.

        method foo ($bar, $baz) {
                $self.boo; # $self always exists in a method
        }

There's no conflict with Perl 5 since C<method> is a new keyword.

Also, the invocant pragma becomes unnecessary if you can always access
the current object via $self (or $this, or $me, or whatever, as long as
it's not $invocant ;).

My, my, my, I *am* playing the devil's advocate today. :)

Allison

Reply via email to