develooper Front page | perl.perl5.porters | Postings from March 2021

Re: De-experimentalising "signatures"

Thread Previous | Thread Next
Paul "LeoNerd" Evans
March 22, 2021 16:55
Re: De-experimentalising "signatures"
Message ID:
On Mon, 22 Mar 2021 17:12:19 +0100
Leon Timmermans <> wrote:

> That does sound reasonable. I'm not sure why we haven't done so
> already; that would have prevented this situation.

Without @_ you can't do arity-checking. E.g. while I personally dislike
the style, a popular thing to do with object accessors is something

  sub name {
    my $self = shift;
    $self->{name} = shift if @_;
    return $self->{name};

That could be written

  sub name ($self, $new = undef) {
    $self->{name} = $new if @_ > 1;
    return $self->{name};

(or something neater with Object::Pad + `method`), but lacking access
to any form of scalar-snail, means we can't distinguish




This is one among a number of reasons why @_ is currently still
required in some situations, for which there are designs on adding more
bits to signatures which will make simpler.

Paul "LeoNerd" Evans      |  |

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