X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/d09258e79780544e1de559476ab3bf5df36f17c7..b3c290c26b9b9e51e5664a73d5f04cd807766b2d:/lib/feature.pm diff --git a/lib/feature.pm b/lib/feature.pm index 78fae2e..ec9fff7 100644 --- a/lib/feature.pm +++ b/lib/feature.pm @@ -5,17 +5,22 @@ package feature; -our $VERSION = '1.33'; +our $VERSION = '1.42'; our %feature = ( fc => 'feature_fc', say => 'feature_say', state => 'feature_state', switch => 'feature_switch', + bitwise => 'feature_bitwise', evalbytes => 'feature_evalbytes', + postderef => 'feature_postderef', array_base => 'feature_arybase', + signatures => 'feature_signatures', current_sub => 'feature___SUB__', + refaliasing => 'feature_refaliasing', lexical_subs => 'feature_lexsubs', + postderef_qq => 'feature_postderef_qq', unicode_eval => 'feature_unieval', unicode_strings => 'feature_unicode', ); @@ -24,7 +29,8 @@ 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)], - "all" => [qw(array_base current_sub evalbytes fc lexical_subs 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)], ); @@ -36,11 +42,14 @@ $feature_bundle{"5.17"} = $feature_bundle{"5.15"}; $feature_bundle{"5.18"} = $feature_bundle{"5.15"}; $feature_bundle{"5.19"} = $feature_bundle{"5.15"}; $feature_bundle{"5.20"} = $feature_bundle{"5.15"}; +$feature_bundle{"5.21"} = $feature_bundle{"5.15"}; +$feature_bundle{"5.22"} = $feature_bundle{"5.15"}; +$feature_bundle{"5.24"} = $feature_bundle{"5.23"}; $feature_bundle{"5.9.5"} = $feature_bundle{"5.10"}; our $hint_shift = 26; our $hint_mask = 0x1c000000; -our @hint_bundles = qw( default 5.10 5.11 5.15 ); +our @hint_bundles = qw( default 5.10 5.11 5.15 5.23 ); # This gets set (for now) in $^H as well as in %^H, # for runtime speed of the uc/lc/ucfirst/lcfirst functions. @@ -129,6 +138,12 @@ This feature is available starting with Perl 5.10. =head2 The 'switch' feature +B: Because the L is +experimental, Perl will warn when you use this feature, unless you have +explicitly disabled the warning: + + no warnings "experimental::smartmatch"; + C tells the compiler to enable the Perl 6 given/when construct. @@ -138,7 +153,7 @@ This feature is available starting with Perl 5.10. =head2 The 'unicode_strings' feature -C tells the compiler to use Unicode semantics +C tells the compiler to use Unicode rules in all string operations executed within its scope (unless they are also within the scope of either C or C). The same applies to all regular expressions compiled within the scope, even if executed outside @@ -146,7 +161,7 @@ it. It does not change the internal representation of strings, but only how they are interpreted. C tells the compiler to use the traditional -Perl semantics wherein the native character set semantics is used unless it is +Perl rules wherein the native character set rules is used unless it is clear to Perl that Unicode is desired. This can lead to some surprises when the behavior suddenly changes. (See L for details.) For this reason, if you are @@ -243,6 +258,94 @@ and C syntax. See L for details. This feature is available from Perl 5.18 onwards. +=head2 The 'postderef' and 'postderef_qq' features + +The 'postderef_qq' feature extends the applicability of L so that postfix array +and scalar dereference are available in double-quotish interpolations. For +example, it makes the following two statements equivalent: + + my $s = "[@{ $h->{a} }]"; + my $s = "[$h->{a}->@*]"; + +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 this feature no longer triggers a warning, though +the C 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 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: 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 for details. + +This feature is available from Perl 5.20 onwards. + +=head2 The 'refaliasing' feature + +B: 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::refaliasing"; + +This enables aliasing via assignment to references: + + \$a = \$b; # $a and $b now point to the same scalar + \@a = \@b; # to the same array + \%a = \%b; + \&a = \&b; + foreach \%hash (@array_of_hash_refs) { + ... + } + +See L for details. + +This feature is available from Perl 5.22 onwards. + +=head2 The 'bitwise' feature + +B: 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::bitwise"; + +This makes the four standard bitwise operators (C<& | ^ ~>) treat their +operands consistently as numbers, and introduces four new dotted operators +(C<&. |. ^. ~.>) that treat their operands consistently as strings. The +same applies to the assignment variants (C<&= |= ^= &.= |.= ^.=>). + +See L for details. + +This feature is available from Perl 5.22 onwards. + =head1 FEATURE BUNDLES It's possible to load multiple features together, using @@ -272,6 +375,13 @@ The following feature bundles are available: :5.20 say state switch unicode_strings unicode_eval evalbytes current_sub fc + :5.22 say state switch unicode_strings + unicode_eval evalbytes current_sub fc + + :5.24 say state switch unicode_strings + unicode_eval evalbytes current_sub fc + postderef_qq + The C<:default> bundle represents the feature set that is enabled before any C or C declaration. @@ -326,7 +436,7 @@ bundle is automatically loaded instead. =cut sub import { - my $class = shift; + shift; if (!@_) { croak("No features specified"); @@ -336,7 +446,7 @@ sub import { } sub unimport { - my $class = shift; + shift; # A bare C should reset to the default bundle if (!@_) {