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

Re: De-experimentalising "signatures"

Thread Previous | Thread Next
From:
Alexander Hartmaier
Date:
March 27, 2021 16:01
Subject:
Re: De-experimentalising "signatures"
Message ID:
CAB49QrbixvHhBWRwQAPuz0qM-XUnmwoKT5H=9coRO1u-tdEi_A@mail.gmail.com
On Sat, Mar 27, 2021 at 1:39 PM Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
wrote:

> On Fri, 26 Mar 2021 22:28:30 -0700
> Darren Duncan <darren@darrenduncan.net> wrote:
>
> > I would propose and expect that @_ should continue to behave the same
> > as it always did, and be available in every subroutine, and that
> > signatures just provides an overlay plus constraint check.
> ...
> > The key thing is that I consider access to a single value
> > representing the entire collection of actual arguments to be an
> > important fundamental feature that should never go away.
>
> I don't think anyone is suggesting to get rid of @_ because they don't
> "like" it, or it's messy or confuses newbies or anything.
>
> The primary motivation to get rid of @_ is that it is slow. It is a
> large performance drain on the overhead of the ENTERSUB op, which is
> involved in every single function call that Perl ever makes. If we were
> able to skip that part for the majority of subs which don't need it
> (because they'd be written with signatures), then the entire program
> runs faster.
>
> Performance is a feature.
>

Oh, I didn't know that!
When I'm using signatures, I replace the @_ usage with them, for example in
https://metacpan.org/pod/Net::Cisco::FMC::v1.
Regarding performance I'd suggest having no @_ in a sub that has a
signature.
As we'll have to keep the signatureless subs with @_ for backcompat for
like forever, I don't see what else there is to discuss?


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