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

Re: De-experimentalising "signatures"

Thread Previous | Thread Next
Paul "LeoNerd" Evans
February 8, 2021 23:46
Re: De-experimentalising "signatures"
Message ID:
On Mon, 8 Feb 2021 10:32:17 +0900
Yuki Kimoto <> wrote:

> My strong complaint about current signature is that by default there
> is a validation check of the number of arguments.
> At least, I hope
> sub func ($foo, $bar) {
> }
> is same as
> sub func  {
>   my ($foo, $bar) = @_;
> }
> My hope is that syntax sugar feature and type checking feature is
> separated.

Honestly, the arity checking is an often-requested feature, and one
that most signature-users find natural and welcome. In my opinion it
has always been an error that perl's regular list assignment in that
case doesn't check.

In fact, one of my possible feature ideas for "Perl in 2025" (see my
FOSDEM talk), was to consider a generic list-assignment operator that
behaves the same as signatures, precisely so you could get the benefit
of that arity checking (as well as defaults and other features). E.g.
you could

  let ($one, $two, $three = 3) = @values;

to have the same length-checking and default-assigning semantics as a

Paul "LeoNerd" Evans      |  |

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