mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 08:38:23 +00:00
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.
This commit is contained in:
parent
4134928828
commit
1c2511e0ac
@ -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 \
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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';
|
||||
|
||||
5
toke.c
5
toke.c
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user