develooper Front page | perl.perl5.porters | Postings from May 2023

Re: Limitations of Attributes

Thread Previous | Thread Next
Paul "LeoNerd" Evans
May 5, 2023 12:49
Re: Limitations of Attributes
Message ID:
On Fri, 5 May 2023 11:58:56 +0100
Dave Mitchell <> wrote:

> Note that in Perl 6 and some CPAN signature modules, the 'method'
> keyword declares an implicit $self parameter, whose name can be
> overridden using a postfix ':':
>     method foo($x, $y)      { $self->{$x} = $y }  # implicit $self
>     method foo($me: $x, $y) {   $me->{$x} = $y }  # explicit invocant
> I have no plans to introduce such a 'method' keyword, but if we did,
> we might need different syntax for the invocant, as the ':' would be
> interpreted as the start of an attribute unless the toker was clever
> and we are very careful that all signature syntax is capable of being
> disambiguated.

A quick note on that part - the newly-added `method` keyword doesn't
allow you to rename the invocant variable at all. You just get `$self`,
so there's no such syntax ambiguity here to worry about.

Paul "LeoNerd" Evans      |  |

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About