diff options
author | Aaron Crane <arc@cpan.org> | 2015-07-13 12:58:51 +0100 |
---|---|---|
committer | Aaron Crane <arc@cpan.org> | 2015-07-13 13:42:01 +0100 |
commit | 1c2511e0acc5a19f9f52fb2be58a4e2750213e6f (patch) | |
tree | 0ddb6e3d668f6fae267867032bcea8fc9d51516e | |
parent | 41349288283615495b6de1523783d60c9fd7310b (diff) | |
download | perl-1c2511e0acc5a19f9f52fb2be58a4e2750213e6f.tar.gz |
Make postfix dereferencing work without the postderef feature
The feature still exists, for compatibility with code that tries to enable
it, but it has no effect. The postderef_qq feature still exists, however.
-rw-r--r-- | feature.h | 5 | ||||
-rw-r--r-- | lib/feature.pm | 31 | ||||
-rw-r--r-- | pod/perldelta.pod | 9 | ||||
-rw-r--r-- | pod/perlref.pod | 8 | ||||
-rwxr-xr-x | regen/feature.pl | 29 | ||||
-rw-r--r-- | t/lib/warnings/toke | 3 | ||||
-rw-r--r-- | t/op/postfixderef.t | 28 | ||||
-rw-r--r-- | toke.c | 5 |
8 files changed, 52 insertions, 66 deletions
@@ -78,9 +78,8 @@ #define FEATURE_POSTDEREF_IS_ENABLED \ ( \ - CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_523 \ - || (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED("postderef")) \ + CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ + FEATURE_IS_ENABLED("postderef") \ ) #define FEATURE_ARYBASE_IS_ENABLED \ diff --git a/lib/feature.pm b/lib/feature.pm index e2076ed8a6..ec9fff7a6d 100644 --- a/lib/feature.pm +++ b/lib/feature.pm @@ -29,7 +29,7 @@ our %feature_bundle = ( "5.10" => [qw(array_base say state switch)], "5.11" => [qw(array_base say state switch unicode_strings)], "5.15" => [qw(current_sub evalbytes fc say state switch unicode_eval unicode_strings)], - "5.23" => [qw(current_sub evalbytes fc postderef postderef_qq say state switch unicode_eval unicode_strings)], + "5.23" => [qw(current_sub evalbytes fc postderef_qq say state switch unicode_eval unicode_strings)], "all" => [qw(array_base bitwise current_sub evalbytes fc lexical_subs postderef postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)], "default" => [qw(array_base)], ); @@ -260,26 +260,31 @@ This feature is available from Perl 5.18 onwards. =head2 The 'postderef' and 'postderef_qq' features -The 'postderef' feature allows the use of L<postfix dereference -syntax|perlref/Postfix Dereference Syntax>. For example, it will make the -following two statements equivalent: +The 'postderef_qq' feature extends the applicability of L<postfix +dereference syntax|perlref/Postfix Dereference Syntax> so that postfix array +and scalar dereference are available in double-quotish interpolations. For +example, it makes the following two statements equivalent: - my @x = @{ $h->{a} }; - my @x = $h->{a}->@*; + my $s = "[@{ $h->{a} }]"; + my $s = "[$h->{a}->@*]"; -The 'postderef_qq' feature extends this, for array and scalar dereference, to -working inside of double-quotish interpolations. - -These features are available from Perl 5.20 onwards. In Perl 5.20 and 5.22, -they were classed as experimental, and Perl emitted a warning for their +This feature is available from Perl 5.20 onwards. In Perl 5.20 and 5.22, it +was classed as experimental, and Perl emitted a warning for its usage, except when explicitly disabled: no warnings "experimental::postderef"; -As of Perl 5.24, use of these features no longer triggers a warning, though +As of Perl 5.24, use of this feature no longer triggers a warning, though the C<experimental::postderef> warning category still exists (for compatibility with code that disables it). +The 'postderef' feature was used in Perl 5.20 and Perl 5.22 to enable +postfix dereference syntax outside double-quotish interpolations. In those +versions, using it triggered the C<experimental::postderef> warning in the +same way as the 'postderef_qq' feature did. As of Perl 5.24, this syntax is +not only no longer experimental, but it is enabled for all Perl code, +regardless of what feature declarations are in scope. + =head2 The 'signatures' feature B<WARNING>: This feature is still experimental and the implementation may @@ -375,7 +380,7 @@ The following feature bundles are available: :5.24 say state switch unicode_strings unicode_eval evalbytes current_sub fc - postderef postderef_qq + postderef_qq The C<:default> bundle represents the feature set that is enabled before any C<use feature> or C<no feature> declaration. diff --git a/pod/perldelta.pod b/pod/perldelta.pod index ce8768b285..ae26fbb327 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -52,9 +52,12 @@ you could use the C<bigint> pragma. =head2 Postfix dereferencing is no longer experimental -Using the C<postderef> and C<postderef_qq> features no longer emits a warning. -Existing code that disables that warning category will continue to work. The -C<5.24> feature bundle now includes those features. +Using the C<postderef> and C<postderef_qq> features no longer emits a +warning. Existing code that disables the C<experimental::postderef> warning +category that they previously used will continue to work. The C<postderef> +feature has no effect; all Perl code can use postfix dereferencing, +regardless of what feature declarations are in scope. The C<5.24> feature +bundle now includes the C<postderef_qq> feature. =head1 Security diff --git a/pod/perlref.pod b/pod/perlref.pod index 8956be5750..e570b72cd3 100644 --- a/pod/perlref.pod +++ b/pod/perlref.pod @@ -758,7 +758,9 @@ For example: $r = [ 1, [ 2, 3 ], 4 ]; $r->[1]->@*; # equivalent to @{ $r->[1] } -This syntax must be enabled with C<use feature 'postderef'>. +In Perl 5.20 and 5.22, this syntax must be enabled with C<use feature +'postderef'>. As of Perl 5.24, no feature declarations are required to make +it available. Postfix dereference should work in all circumstances where block (circumfix) dereference worked, and should be entirely equivalent. This @@ -781,7 +783,7 @@ Glob elements can be extracted through the postfix dereferencing feature: Postfix array and scalar dereferencing I<can> be used in interpolating strings (double quotes or the C<qq> operator), but only if the -additional C<postderef_qq> feature is enabled. +C<postderef_qq> feature is enabled. =head2 Postfix Reference Slicing @@ -800,7 +802,7 @@ Slices">, also behaves as expected: As with postfix array, postfix value slice dereferencing I<can> be used in interpolating strings (double quotes or the C<qq> operator), but only -if the additional C<postderef_qq> L<feature> is enabled. +if the C<postderef_qq> L<feature> is enabled. =head1 Assigning to References diff --git a/regen/feature.pl b/regen/feature.pl index a7b6e5de29..85ab2b034b 100755 --- a/regen/feature.pl +++ b/regen/feature.pl @@ -60,7 +60,7 @@ my %feature_bundle = ( "5.21" => [qw(say state switch unicode_strings unicode_eval evalbytes current_sub fc)], "5.23" => [qw(say state switch unicode_strings unicode_eval - evalbytes current_sub fc postderef postderef_qq)], + evalbytes current_sub fc postderef_qq)], ); # not actually used currently @@ -575,26 +575,31 @@ This feature is available from Perl 5.18 onwards. =head2 The 'postderef' and 'postderef_qq' features -The 'postderef' feature allows the use of L<postfix dereference -syntax|perlref/Postfix Dereference Syntax>. For example, it will make the -following two statements equivalent: +The 'postderef_qq' feature extends the applicability of L<postfix +dereference syntax|perlref/Postfix Dereference Syntax> so that postfix array +and scalar dereference are available in double-quotish interpolations. For +example, it makes the following two statements equivalent: - my @x = @{ $h->{a} }; - my @x = $h->{a}->@*; + my $s = "[@{ $h->{a} }]"; + my $s = "[$h->{a}->@*]"; -The 'postderef_qq' feature extends this, for array and scalar dereference, to -working inside of double-quotish interpolations. - -These features are available from Perl 5.20 onwards. In Perl 5.20 and 5.22, -they were classed as experimental, and Perl emitted a warning for their +This feature is available from Perl 5.20 onwards. In Perl 5.20 and 5.22, it +was classed as experimental, and Perl emitted a warning for its usage, except when explicitly disabled: no warnings "experimental::postderef"; -As of Perl 5.24, use of these features no longer triggers a warning, though +As of Perl 5.24, use of this feature no longer triggers a warning, though the C<experimental::postderef> warning category still exists (for compatibility with code that disables it). +The 'postderef' feature was used in Perl 5.20 and Perl 5.22 to enable +postfix dereference syntax outside double-quotish interpolations. In those +versions, using it triggered the C<experimental::postderef> warning in the +same way as the 'postderef_qq' feature did. As of Perl 5.24, this syntax is +not only no longer experimental, but it is enabled for all Perl code, +regardless of what feature declarations are in scope. + =head2 The 'signatures' feature B<WARNING>: This feature is still experimental and the implementation may diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index d65467c218..ad0e74b7d1 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -1040,10 +1040,9 @@ EXPECT Useless use of \E at - line 3. ######## # toke.c -use feature 'postderef', 'postderef_qq'; +use feature 'postderef_qq'; (\$_)->$*; "$_->$*"; -no warnings 'experimental::postderef'; (\$_)->$*; "$_->$*"; EXPECT diff --git a/t/op/postfixderef.t b/t/op/postfixderef.t index 920bc2db23..77988bfd3c 100644 --- a/t/op/postfixderef.t +++ b/t/op/postfixderef.t @@ -16,33 +16,7 @@ BEGIN { use strict qw(refs subs); -plan(125); - -{ - no warnings qw 'deprecated syntax'; - eval '[]->$*'; - like $@, qr/Can't call method/, '->$* outside of feature scope'; - eval '[]->@*'; - like $@, qr/syntax error/, '->@* outside of feature scope'; - eval '[]->@[1]'; - like $@, qr/syntax error/, '->@[ outside of feature scope'; - eval '[]->@{1}'; - like $@, qr/syntax error/, '->@{ outside of feature scope'; - eval '[]->%*'; - like $@, qr/syntax error/, '->%* outside of feature scope'; - eval '[]->%[1]'; - like $@, qr/syntax error/, '->%[ outside of feature scope'; - eval '[]->%{1}'; - like $@, qr/syntax error/, '->%{ outside of feature scope'; - eval '[]->&*'; - like $@, qr/syntax error/, '->&* outside of feature scope'; - eval '[]->**'; - like $@, qr/syntax error/, '->** outside of feature scope'; - eval '[]->*{'; - like $@, qr/syntax error/, '->*{ outside of feature scope'; -} - -use feature 'postderef'; +plan(115); { no strict 'refs'; @@ -5133,12 +5133,11 @@ Perl_yylex(pTHX) else if (*s == '>') { s++; s = skipspace(s); - if (FEATURE_POSTDEREF_IS_ENABLED && ( - ((*s == '$' || *s == '&') && s[1] == '*') + if (((*s == '$' || *s == '&') && s[1] == '*') ||(*s == '$' && s[1] == '#' && s[2] == '*') ||((*s == '@' || *s == '%') && strchr("*[{", s[1])) ||(*s == '*' && (s[1] == '*' || s[1] == '{')) - )) + ) { PL_expect = XPOSTDEREF; TOKEN(ARROW); |