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

Re: De-experimentalising "signatures"

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
February 10, 2021 12:25
Subject:
Re: De-experimentalising "signatures"
Message ID:
20210210122522.094e3740@shy.leonerd.org.uk
On Wed, 10 Feb 2021 16:28:34 +0900
Yuki Kimoto <kimoto.yuki@gmail.com> wrote:

> > 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.

"Sweeping judgements are, in general, usually correct" ;)

Given any statement about a large collection of people, there'll almost
always be some people who don't fit it. And in the field of computer
language design, for any given feature, there will always be some
people who love it and some who hate it. 

> 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) { }

Now I admit I don't know JavaScript, but it would surprise me if you
didn't get any sort of runtime error when trying to call either of

  func(1);
  func(1,2,3);

> "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.

I think the vast swathe of CPAN modules where people try to hack on all
sorts of such concepts into the language suggests that there are lots
of users who think that. A few that I recall offhand:

  https://metacpan.org/pod/Function::Parameters
  https://metacpan.org/pod/MooseX::Function::Parameters
  https://metacpan.org/pod/Params::Validate

Admittedly some of these are more cumbersome and less expressive to
actually use than would be liked, because they are constrained by
having to appear like currently-valid Perl syntax.

It is our job as the architects and maintainers of the language itself
to regularly take a look out into the real world, see what things
people are actually doing, and provide them better tools for doing that.

-- 
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