Skip to content

Commit

Permalink
Add @_ in signatured sub being experimental to perldelta.pod
Browse files Browse the repository at this point in the history
  • Loading branch information
leonerd committed Jan 31, 2022
1 parent 449fd5f commit a6a6eee
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pod/perldelta.pod
Expand Up @@ -27,6 +27,34 @@ here, but most should go in the L</Performance Enhancements> section.

[ List each enhancement as a =head2 entry ]

=head2 @_ is now experimental within signatured subs

Even though subroutine signatures currently remain experimental, use of the
default arguments array (C<@_>) with a subroutine that has a signature is
specifically also experimental, with its own warning category. Silencing the
C<experimental::signatures> warning category is not sufficient to dismiss
this. The new warning is emitted with the category name
C<experimental::args_array_with_signatures>.

Any subroutine that has a signature and tries to make use of the defaults
argument array or an element thereof (C<@_> or C<$_[INDEX]>), either
explicitly or implicitly (such as C<shift> or C<pop> with no argument) will
provoke a warning at compile-time:

use experimental 'signatures';

sub f ($x, $y = 123) {
say "The first argument is $_[0]";
}

Z<>

Use of @_ in array element with signatured subroutine is experimental
at file.pl line 4.

The behaviour of code which attempts to do this is no longer specified, and
may be subject to change in a future version.

=head1 Security

XXX Any security-related notices go here. In particular, any security
Expand Down

0 comments on commit a6a6eee

Please sign in to comment.