diff options
author | Zefram <zefram@fysh.org> | 2014-02-01 01:27:13 +0000 |
---|---|---|
committer | Zefram <zefram@fysh.org> | 2014-02-01 01:27:15 +0000 |
commit | 30d9c59b5f3cba8b5d632d20c2370e82d8ba69ca (patch) | |
tree | 989db43c82b395cec053b341532db7a145827254 /regen/feature.pl | |
parent | ef463b6d87c1ce4e4946bdf785d47e481c1f33f2 (diff) | |
download | perl-30d9c59b5f3cba8b5d632d20c2370e82d8ba69ca.tar.gz |
subroutine signatures
Declarative syntax to unwrap argument list into lexical variables.
"sub foo ($a,$b) {...}" checks number of arguments and puts the
arguments into lexical variables. Signatures are not equivalent to the
existing idiom of "sub foo { my($a,$b) = @_; ... }". Signatures are only
available by enabling a non-default feature, and generate warnings about
being experimental. The syntactic clash with prototypes is managed by
disabling the short prototype syntax when signatures are enabled.
Diffstat (limited to 'regen/feature.pl')
-rwxr-xr-x | regen/feature.pl | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/regen/feature.pl b/regen/feature.pl index d43abc0684..a46ebbcc91 100755 --- a/regen/feature.pl +++ b/regen/feature.pl @@ -34,6 +34,7 @@ my %feature = ( unicode_eval => 'unieval', unicode_strings => 'unicode', fc => 'fc', + signatures => 'signatures', ); # NOTE: If a feature is ever enabled in a non-contiguous range of Perl @@ -360,7 +361,7 @@ read_only_bottom_close_and_rename($h); __END__ package feature; -our $VERSION = '1.34'; +our $VERSION = '1.35'; FEATURES @@ -560,6 +561,26 @@ and C<our sub foo> syntax. See L<perlsub/Lexical Subroutines> for details. This feature is available from Perl 5.18 onwards. +=head2 The 'signatures' feature + +B<WARNING>: This feature is still experimental and the implementation may +change in future versions of Perl. For this reason, Perl will +warn when you use the feature, unless you have explicitly disabled the +warning: + + no warnings "experimental::signatures"; + +This enables unpacking of subroutine arguments into lexical variables +by syntax such as + + sub foo ($left, $right) { + return $left + $right; + } + +See L<perlsub/Signatures> for details. + +This feature is available from Perl 5.20 onwards. + =head1 FEATURE BUNDLES It's possible to load multiple features together, using |