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

Re: De-experimentalising "signatures"

Thread Previous | Thread Next
From:
Yuki Kimoto
Date:
February 10, 2021 07:28
Subject:
Re: De-experimentalising "signatures"
Message ID:
CAExogxNP_3=ZAy6emX=c7hyiHJt5bgUtUQP_r1VVqOCYTKF=_A@mail.gmail.com
> Honestly, the arity checking is an often-requested feature, and one
that most signature-users find natural and welcome.

Sorry,
When you say most,
My existence doesn't seem to be included there.

I like the idea that Perl has no constraints by default.

I also want the signature to be designed to be unconstrained by default.

That seems like javascript

function func(foo, bar) { }

"sub_args" may be more appropriate name than the name "signatures".

I agree that some users think they need an arity check and type checking.

so based on the above syntax, arity check and runtime type validation
are designed.


2021年2月9日(火) 8:46 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>:

> On Mon, 8 Feb 2021 10:32:17 +0900
> Yuki Kimoto <kimoto.yuki@gmail.com> 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
> signature.
>
> --
> Paul "LeoNerd" Evans
>
> leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
> http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/
>

Thread Previous | Thread Next


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