#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 \
"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)],
);
=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
: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.
=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
$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
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
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
"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
=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
Useless use of \E at - line 3.
########
# toke.c
-use feature 'postderef', 'postderef_qq';
+use feature 'postderef_qq';
(\$_)->$*;
"$_->$*";
-no warnings 'experimental::postderef';
(\$_)->$*;
"$_->$*";
EXPECT
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';
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);