develooper Front page | perl.perl5.porters | Postings from November 2016

Re: RFC: core sub signature introspection

Thread Previous | Thread Next
From:
Aaron Crane
Date:
November 24, 2016 19:25
Subject:
Re: RFC: core sub signature introspection
Message ID:
CACmk_ttjHY4qRTCMXV8owZ68WCn1+yVALAW49PHxqAWmyv8X6g@mail.gmail.com
Abigail <abigail@abigail.be> wrote:
> If code gets to introspect a subroutine signature, it's no longer
> the case that:
>
>     sub some_sub ($foo, $bar, $baz) {
>        ...
>     }
>
> is just a programmer friendly way of writing
>
>     sub some_sub {
>         my ($foo, $bar, $baz) = @_;
>         ...
>     }

Just to clarify for anyone who wasn't aware, those two snippets aren't
entirely equivalent, in that only the former implementation performs
arity checking.

That said, my own view is that this an excellent thing. For example,
earlier today I was puzzled for a few minutes by a confusing error in
some code I'd just written. When I realised I'd simply omitted a
subroutine argument, I dearly wished that the codebase in question was
using arity-checked signatures: the error message would have contained
ample information for me to immediately fix the underlying problem.

-- 
Aaron Crane ** http://aaroncrane.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