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

Re: RFC: core sub signature introspection

Thread Previous | Thread Next
Aaron Crane
November 24, 2016 19:25
Re: RFC: core sub signature introspection
Message ID:
Abigail <> 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 **

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About