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

Re: De-experimentalising "signatures"

Thread Previous | Thread Next
From:
Sam Kington
Date:
February 9, 2021 01:05
Subject:
Re: De-experimentalising "signatures"
Message ID:
8106E13A-A9B9-449E-9494-31674EA23D70@illuminated.co.uk
I didn’t want to randomly +1 earlier, but in my previous place we used signatures with gay abandon, and if we weren’t pinned to a too-early version of Perl at my current place, for tech debt and/or regulatory reasons, I think we’d adopt them here too.

Maybe more substantively:

On 8 Feb 2021, at 23:46, Paul LeoNerd Evans <leonerd@leonerd.org.uk> wrote:
> 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.

That sounds really good. What would be even better would be if the Perl debugger either (a) recognised that it couldn’t introspect what was going on and just skipped the entire thing, or (b) exposed the checks that were happening.

As it is, if I’m dealing with Moose code, I can either decide to put “ignore all of Moose, I don’t want to know” in my .perldb, or I can recognise that I’m unexpectedly in the middle of Moose guts and bloody-mindedly single-step my way out of there / ragequit and reconsider. But when I hit signatures in the debugger, I can hammer on the n key for 3 or 4 times without anything obviously happening.

I appreciate that, internally, signatures are being translated to machine-generated Perl code that checks the arguments, but that’s not source code that the debugger can show me so it just smiles and nods and hopes that everything will work out fine. But it means that I can’t tell *why*, precisely, my arguments are being rejected.

If this isn’t a known problem I’m happy to raise an issue on GitHub or something.

Sam
-- 
Website: http://www.illuminated.co.uk/


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