From e1d9c8faafa19acd2e842af2ea93dd0eaed500c2 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Fri, 14 Mar 2025 11:39:34 +0000 Subject: [PATCH 1/2] Refactor regen/feature.pl: Most features are same-named internally and publicly so simplify data structure shape --- regen/feature.pl | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/regen/feature.pl b/regen/feature.pl index 1fcc62c09d4a..0747a3d32776 100755 --- a/regen/feature.pl +++ b/regen/feature.pl @@ -24,32 +24,37 @@ BEGIN # (feature name) => (internal name, used in %^H and macro names) my %feature = ( - say => 'say', - state => 'state', - switch => 'switch', - bitwise => 'bitwise', - evalbytes => 'evalbytes', + # A few features are publicly named differently than internally current_sub => '__SUB__', - refaliasing => 'refaliasing', - postderef_qq => 'postderef_qq', unicode_eval => 'unieval', declared_refs => 'myref', unicode_strings => 'unicode', - fc => 'fc', - signatures => 'signatures', - isa => 'isa', - indirect => 'indirect', - multidimensional => 'multidimensional', - bareword_filehandles => 'bareword_filehandles', - try => 'try', - defer => 'defer', extra_paired_delimiters => 'more_delims', - module_true => 'module_true', - class => 'class', apostrophe_as_package_separator => 'apos_as_name_sep', - any => 'any', - all => 'all', - smartmatch => 'smartmatch', + + # Most features have identical public and internal names + map { $_ => $_ } qw( + say + state + switch + bitwise + evalbytes + refaliasing + postderef_qq + fc + signatures + isa + indirect + multidimensional + bareword_filehandles + try + defer + module_true + class + any + all + smartmatch + ) ); # NOTE: If a feature is ever enabled in a non-contiguous range of Perl From 28be74a150f6b38cbb5f7fb802a8fab3d6651816 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Fri, 14 Mar 2025 11:57:56 +0000 Subject: [PATCH 2/2] Rename the 'any' and 'all' features and experimental warnings to 'keyword_any' and 'keyword_all' This avoids confusion with the `use feature ':all'` ability (As requested by https://github.com/Perl/perl5/issues/23104) --- feature.h | 113 ++++++++++++++++++++++--------------------- keywords.c | 6 +-- keywords.h | 2 +- lib/B/Deparse-core.t | 2 +- lib/feature.pm | 20 +++----- lib/warnings.pm | 22 ++++----- pod/perldelta.pod | 27 +++++++++++ pod/perldiag.pod | 8 +-- pod/perlfunc.pod | 4 +- regen/feature.pl | 18 +++---- regen/keywords.pl | 5 +- regen/warnings.pl | 6 +-- t/lib/croak/op | 8 +-- t/op/any_all.t | 4 +- toke.c | 4 +- warnings.h | 8 +-- 16 files changed, 140 insertions(+), 117 deletions(-) diff --git a/feature.h b/feature.h index f3ad3b077e25..51de8ce4a00d 100644 --- a/feature.h +++ b/feature.h @@ -13,20 +13,20 @@ #define HINT_FEATURE_SHIFT 26 /* Index 0 */ -#define FEATURE_ALL_BIT 0x00000001 -#define FEATURE_ANY_BIT 0x00000002 -#define FEATURE_APOS_AS_NAME_SEP_BIT 0x00000004 -#define FEATURE_BAREWORD_FILEHANDLES_BIT 0x00000008 -#define FEATURE_BITWISE_BIT 0x00000010 -#define FEATURE_CLASS_BIT 0x00000020 -#define FEATURE___SUB___BIT 0x00000040 -#define FEATURE_MYREF_BIT 0x00000080 -#define FEATURE_DEFER_BIT 0x00000100 -#define FEATURE_EVALBYTES_BIT 0x00000200 -#define FEATURE_MORE_DELIMS_BIT 0x00000400 -#define FEATURE_FC_BIT 0x00000800 -#define FEATURE_INDIRECT_BIT 0x00001000 -#define FEATURE_ISA_BIT 0x00002000 +#define FEATURE_APOS_AS_NAME_SEP_BIT 0x00000001 +#define FEATURE_BAREWORD_FILEHANDLES_BIT 0x00000002 +#define FEATURE_BITWISE_BIT 0x00000004 +#define FEATURE_CLASS_BIT 0x00000008 +#define FEATURE___SUB___BIT 0x00000010 +#define FEATURE_MYREF_BIT 0x00000020 +#define FEATURE_DEFER_BIT 0x00000040 +#define FEATURE_EVALBYTES_BIT 0x00000080 +#define FEATURE_MORE_DELIMS_BIT 0x00000100 +#define FEATURE_FC_BIT 0x00000200 +#define FEATURE_INDIRECT_BIT 0x00000400 +#define FEATURE_ISA_BIT 0x00000800 +#define FEATURE_KEYWORD_ALL_BIT 0x00001000 +#define FEATURE_KEYWORD_ANY_BIT 0x00002000 #define FEATURE_MODULE_TRUE_BIT 0x00004000 #define FEATURE_MULTIDIMENSIONAL_BIT 0x00008000 #define FEATURE_POSTDEREF_QQ_BIT 0x00010000 @@ -40,8 +40,6 @@ #define FEATURE_UNIEVAL_BIT 0x01000000 #define FEATURE_UNICODE_BIT 0x02000000 -#define FEATURE_ALL_INDEX 0 -#define FEATURE_ANY_INDEX 0 #define FEATURE_APOS_AS_NAME_SEP_INDEX 0 #define FEATURE_BAREWORD_FILEHANDLES_INDEX 0 #define FEATURE_BITWISE_INDEX 0 @@ -54,6 +52,8 @@ #define FEATURE_FC_INDEX 0 #define FEATURE_INDIRECT_INDEX 0 #define FEATURE_ISA_INDEX 0 +#define FEATURE_KEYWORD_ALL_INDEX 0 +#define FEATURE_KEYWORD_ANY_INDEX 0 #define FEATURE_MODULE_TRUE_INDEX 0 #define FEATURE_MULTIDIMENSIONAL_INDEX 0 #define FEATURE_POSTDEREF_QQ_INDEX 0 @@ -111,18 +111,6 @@ FEATURE_IS_ENABLED_MASK(FEATURE_FC_INDEX, FEATURE_FC_BIT)) \ ) -#define FEATURE_ALL_IS_ENABLED \ - ( \ - CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED_MASK(FEATURE_ALL_INDEX, FEATURE_ALL_BIT) \ - ) - -#define FEATURE_ANY_IS_ENABLED \ - ( \ - CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ - FEATURE_IS_ENABLED_MASK(FEATURE_ANY_INDEX, FEATURE_ANY_BIT) \ - ) - #define FEATURE_ISA_IS_ENABLED \ ( \ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_535 && \ @@ -221,6 +209,18 @@ FEATURE_IS_ENABLED_MASK(FEATURE___SUB___INDEX, FEATURE___SUB___BIT)) \ ) +#define FEATURE_KEYWORD_ALL_IS_ENABLED \ + ( \ + CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ + FEATURE_IS_ENABLED_MASK(FEATURE_KEYWORD_ALL_INDEX, FEATURE_KEYWORD_ALL_BIT) \ + ) + +#define FEATURE_KEYWORD_ANY_IS_ENABLED \ + ( \ + CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ + FEATURE_IS_ENABLED_MASK(FEATURE_KEYWORD_ANY_INDEX, FEATURE_KEYWORD_ANY_BIT) \ + ) + #define FEATURE_MODULE_TRUE_IS_ENABLED \ ( \ (CURRENT_FEATURE_BUNDLE >= FEATURE_BUNDLE_537 && \ @@ -373,19 +373,7 @@ S_magic_sethint_feature(pTHX_ SV *keysv, const char *keypv, STRLEN keylen, return; case 'a': - if (keylen == sizeof("feature_all")-1 - && memcmp(subf+1, "ll", keylen - sizeof("feature_")) == 0) { - mask = FEATURE_ALL_BIT; - index = FEATURE_ALL_INDEX; - break; - } - else if (keylen == sizeof("feature_any")-1 - && memcmp(subf+1, "ny", keylen - sizeof("feature_")) == 0) { - mask = FEATURE_ANY_BIT; - index = FEATURE_ANY_INDEX; - break; - } - else if (keylen == sizeof("feature_apos_as_name_sep")-1 + if (keylen == sizeof("feature_apos_as_name_sep")-1 && memcmp(subf+1, "pos_as_name_sep", keylen - sizeof("feature_")) == 0) { mask = FEATURE_APOS_AS_NAME_SEP_BIT; index = FEATURE_APOS_AS_NAME_SEP_INDEX; @@ -459,6 +447,21 @@ S_magic_sethint_feature(pTHX_ SV *keysv, const char *keypv, STRLEN keylen, } return; + case 'k': + if (keylen == sizeof("feature_keyword_all")-1 + && memcmp(subf+1, "eyword_all", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_KEYWORD_ALL_BIT; + index = FEATURE_KEYWORD_ALL_INDEX; + break; + } + else if (keylen == sizeof("feature_keyword_any")-1 + && memcmp(subf+1, "eyword_any", keylen - sizeof("feature_")) == 0) { + mask = FEATURE_KEYWORD_ANY_BIT; + index = FEATURE_KEYWORD_ANY_INDEX; + break; + } + return; + case 'm': if (keylen == sizeof("feature_module_true")-1 && memcmp(subf+1, "odule_true", keylen - sizeof("feature_")) == 0) { @@ -584,20 +587,6 @@ struct perl_feature_bit { static const struct perl_feature_bit PL_feature_bits[] = { - { - /* feature all */ - "feature_all", - STRLENs("feature_all"), - FEATURE_ALL_BIT, - FEATURE_ALL_INDEX - }, - { - /* feature any */ - "feature_any", - STRLENs("feature_any"), - FEATURE_ANY_BIT, - FEATURE_ANY_INDEX - }, { /* feature apostrophe_as_package_separator */ "feature_apos_as_name_sep", @@ -682,6 +671,20 @@ PL_feature_bits[] = { FEATURE_ISA_BIT, FEATURE_ISA_INDEX }, + { + /* feature keyword_all */ + "feature_keyword_all", + STRLENs("feature_keyword_all"), + FEATURE_KEYWORD_ALL_BIT, + FEATURE_KEYWORD_ALL_INDEX + }, + { + /* feature keyword_any */ + "feature_keyword_any", + STRLENs("feature_keyword_any"), + FEATURE_KEYWORD_ANY_BIT, + FEATURE_KEYWORD_ANY_INDEX + }, { /* feature module_true */ "feature_module_true", diff --git a/keywords.c b/keywords.c index c5ddc821db86..53877c7366cd 100644 --- a/keywords.c +++ b/keywords.c @@ -229,7 +229,7 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) case 'l': if (name[2] == 'l') { /* all */ - return (all_keywords || FEATURE_ALL_IS_ENABLED ? -KEY_all : 0); + return (all_keywords || FEATURE_KEYWORD_ALL_IS_ENABLED ? -KEY_all : 0); } goto unknown; @@ -244,7 +244,7 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) case 'y': { /* any */ - return (all_keywords || FEATURE_ANY_IS_ENABLED ? -KEY_any : 0); + return (all_keywords || FEATURE_KEYWORD_ANY_IS_ENABLED ? -KEY_any : 0); } default: @@ -3590,5 +3590,5 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords) } /* Generated from: - * c98bc3e43d3c015df56352665f8ae920fbfb3e2a035f4ce63dcc242190d25c9a regen/keywords.pl + * ad2656c0264d45b03ee74855fdffeffd57799d21d85991fbad0c541b732c9880 regen/keywords.pl * ex: set ro ft=c: */ diff --git a/keywords.h b/keywords.h index 8ac9b3d97d39..922065bc9482 100644 --- a/keywords.h +++ b/keywords.h @@ -282,5 +282,5 @@ #define KEY_y 266 /* Generated from: - * c98bc3e43d3c015df56352665f8ae920fbfb3e2a035f4ce63dcc242190d25c9a regen/keywords.pl + * ad2656c0264d45b03ee74855fdffeffd57799d21d85991fbad0c541b732c9880 regen/keywords.pl * ex: set ro ft=c: */ diff --git a/lib/B/Deparse-core.t b/lib/B/Deparse-core.t index 4b12aad921c6..eb125a6e8d44 100644 --- a/lib/B/Deparse-core.t +++ b/lib/B/Deparse-core.t @@ -92,7 +92,7 @@ sub testit { else { package test; use subs (); - no warnings qw( experimental::any experimental::all ); + no warnings qw( experimental::keyword_any experimental::keyword_all ); import subs $keyword; $code = "no warnings 'syntax'; no strict 'vars'; sub { ${vars}() = $expr }"; $code = "use feature 'isa';\n$code" if $keyword eq "isa"; diff --git a/lib/feature.pm b/lib/feature.pm index ead236e12263..9b0b8d5e6af7 100644 --- a/lib/feature.pm +++ b/lib/feature.pm @@ -4,12 +4,10 @@ # Any changes made here will be lost! package feature; -our $VERSION = '1.94'; +our $VERSION = '1.95'; our %feature = ( fc => 'feature_fc', - all => 'feature_all', - any => 'feature_any', isa => 'feature_isa', say => 'feature_say', try => 'feature_try', @@ -23,6 +21,8 @@ our %feature = ( signatures => 'feature_signatures', smartmatch => 'feature_smartmatch', current_sub => 'feature___SUB__', + keyword_all => 'feature_keyword_all', + keyword_any => 'feature_keyword_any', module_true => 'feature_module_true', refaliasing => 'feature_refaliasing', postderef_qq => 'feature_postderef_qq', @@ -45,7 +45,7 @@ our %feature_bundle = ( "5.37" => [qw(apostrophe_as_package_separator bitwise current_sub evalbytes fc isa module_true postderef_qq say signatures smartmatch state unicode_eval unicode_strings)], "5.39" => [qw(apostrophe_as_package_separator bitwise current_sub evalbytes fc isa module_true postderef_qq say signatures smartmatch state try unicode_eval unicode_strings)], "5.41" => [qw(bitwise current_sub evalbytes fc isa module_true postderef_qq say signatures state try unicode_eval unicode_strings)], - "all" => [qw(all any apostrophe_as_package_separator bareword_filehandles bitwise class current_sub declared_refs defer evalbytes extra_paired_delimiters fc indirect isa module_true multidimensional postderef_qq refaliasing say signatures smartmatch state switch try unicode_eval unicode_strings)], + "all" => [qw(apostrophe_as_package_separator bareword_filehandles bitwise class current_sub declared_refs defer evalbytes extra_paired_delimiters fc indirect isa keyword_all keyword_any module_true multidimensional postderef_qq refaliasing say signatures smartmatch state switch try unicode_eval unicode_strings)], "default" => [qw(apostrophe_as_package_separator bareword_filehandles indirect multidimensional smartmatch)], ); @@ -550,35 +550,31 @@ This only disables C<'> in symbols in your source code, the internal conversion from C<'> to C<::>, including for symbolic references, is always enabled. -=head2 The 'any' feature +=head2 The 'keyword_any' feature B: This feature is still experimental and the implementation may change or be removed 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::any"; + no warnings "experimental::keyword_any"; This feature enables the L|perlfunc/any BLOCK LIST> operator keyword. This allow testing whether any of the values in a list satisfy a given condition, with short-circuiting behaviour as soon as it finds one. -=head2 The 'all' feature +=head2 The 'keyword_all' feature B: This feature is still experimental and the implementation may change or be removed 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::all"; + no warnings "experimental::keyword_all"; This feature enables the L|perlfunc/all BLOCK LIST> operator keyword. This allow testing whether all of the values in a list satisfy a given condition, with short-circuiting behaviour as soon as it finds one that does not. -B remember that this enables one specific feature whose name is C; -it does not enable all of the features. This is not C. -For that, see the section below. - =head1 FEATURE BUNDLES It's possible to load multiple features together, using diff --git a/lib/warnings.pm b/lib/warnings.pm index 5811d376c963..5e3a483b22e3 100644 --- a/lib/warnings.pm +++ b/lib/warnings.pm @@ -5,7 +5,7 @@ package warnings; -our $VERSION = "1.73"; +our $VERSION = "1.74"; # Verify that we're called correctly so that warnings will work. # Can't use Carp, since Carp uses us! @@ -131,8 +131,8 @@ our %Offsets = ( 'deprecated::subsequent_use_version'=> 154, # Warnings Categories added in Perl 5.041 - 'experimental::all' => 156, - 'experimental::any' => 158, + 'experimental::keyword_all' => 156, + 'experimental::keyword_any' => 158, ); our %Bits = ( @@ -154,14 +154,14 @@ our %Bits = ( 'exec' => "\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] 'exiting' => "\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] 'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x05\x04\x55\x55\x40\x50", # [53,54,56,57,61,64..71,75,78,79] - 'experimental::all' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [78] - 'experimental::any' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40", # [79] 'experimental::args_array_with_signatures'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00", # [68] 'experimental::builtin' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00", # [69] 'experimental::class' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [75] 'experimental::declared_refs' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [61] 'experimental::defer' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00", # [70] 'experimental::extra_paired_delimiters'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [71] + 'experimental::keyword_all' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [78] + 'experimental::keyword_any' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40", # [79] 'experimental::private_use' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [64] 'experimental::re_strict' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00", # [56] 'experimental::refaliasing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00", # [57] @@ -237,14 +237,14 @@ our %DeadBits = ( 'exec' => "\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] 'exiting' => "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] 'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x28\x0a\x08\xaa\xaa\x80\xa0", # [53,54,56,57,61,64..71,75,78,79] - 'experimental::all' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [78] - 'experimental::any' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80", # [79] 'experimental::args_array_with_signatures'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00", # [68] 'experimental::builtin' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00", # [69] 'experimental::class' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [75] 'experimental::declared_refs' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [61] 'experimental::defer' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00", # [70] 'experimental::extra_paired_delimiters'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [71] + 'experimental::keyword_all' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [78] + 'experimental::keyword_any' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80", # [79] 'experimental::private_use' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [64] 'experimental::re_strict' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00", # [56] 'experimental::refaliasing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00", # [57] @@ -939,10 +939,6 @@ The current hierarchy is: | +- experimental --+ | | - | +- experimental::all - | | - | +- experimental::any - | | | +- experimental::args_array_with_signatures | | | +- experimental::builtin @@ -955,6 +951,10 @@ The current hierarchy is: | | | +- experimental::extra_paired_delimiters | | + | +- experimental::keyword_all + | | + | +- experimental::keyword_any + | | | +- experimental::private_use | | | +- experimental::re_strict diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 74b6ef269bec..85dcfd3910a4 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -27,6 +27,33 @@ here, but most should go in the L section. [ List each enhancement as a =head2 entry ] +=head2 Renamed C and C features to C and C + +Perl release 5.41.7 introduced two new experimental features, called C +and C, which enable keywords of the same names. Those keywords provide +list-processing operators inspired by the ones from L of the same +name. It was subsequently considered that the names of these two features +are confusingly close to the ability of the C module to refer to all +of its features by using the C<:all> export tag. +(L). + +As a consequence, these feature flags have now been renamed to C +and C to avoid this confusion. Likewise, the related +experimental warning flags are also renamed to C +and C. Apart from these new flag names, the +actual syntax and semantics of these two operators remains unchanged since +their appearance in Perl release 5.41.7. + + use v5.40; + use feature 'keyword_all'; + no warnings 'experimental::keyword_all'; + + my @numbers = ... + + if(all { $_ % 2 == 0 } @numbers) { + say "All the numbers are even"; + } + =head1 Security XXX Any security-related notices go here. In particular, any security diff --git a/pod/perldiag.pod b/pod/perldiag.pod index cc378715f35d..b078f95c6d21 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -77,8 +77,8 @@ removed in a future Perl version: =item all is experimental -(S experimental::all) This warning is emitted if you use the C -keyword of C. This keyword is currently +(S experimental::keyword_all) This warning is emitted if you use the +C keyword of C. This keyword is currently experimental and its behaviour may change in future releases of Perl. =item '%c' allowed only after types %s in %s @@ -190,8 +190,8 @@ which 'splits' output into two streams, such as =item any is experimental -(S experimental::any) This warning is emitted if you use the C -keyword of C. This keyword is currently +(S experimental::keyword_any) This warning is emitted if you use the +C keyword of C. This keyword is currently experimental and its behaviour may change in future releases of Perl. =item Applying %s to %s will act on scalar(%s) diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 4893f1e98ce5..647566ee6895 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -832,7 +832,7 @@ is roughly equivalent to if( @strings == grep { length $_ } @strings ) ... This operator is only available if the -L feature|feature/"The 'all' feature"> is enabled. +L feature|feature/"The 'keyword_all' feature"> is enabled. It is currently considered B, and will issue a compile-time warning in the category C unless that category is silenced. @@ -862,7 +862,7 @@ is roughly equivalent to if( grep { length $_ } @strings ) ... This operator is only available if the -L feature|feature/"The 'any' feature"> is enabled. +L feature|feature/"The 'keyword_any' feature"> is enabled. It is currently considered B, and will issue a compile-time warning in the category C unless that category is silenced. diff --git a/regen/feature.pl b/regen/feature.pl index 0747a3d32776..94b598a0c139 100755 --- a/regen/feature.pl +++ b/regen/feature.pl @@ -51,8 +51,8 @@ BEGIN defer module_true class - any - all + keyword_any + keyword_all smartmatch ) ); @@ -618,7 +618,7 @@ sub longest { __END__ package feature; -our $VERSION = '1.94'; +our $VERSION = '1.95'; FEATURES @@ -1081,35 +1081,31 @@ =head2 The 'apostrophe_as_package_separator' feature conversion from C<'> to C<::>, including for symbolic references, is always enabled. -=head2 The 'any' feature +=head2 The 'keyword_any' feature B: This feature is still experimental and the implementation may change or be removed 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::any"; + no warnings "experimental::keyword_any"; This feature enables the L|perlfunc/any BLOCK LIST> operator keyword. This allow testing whether any of the values in a list satisfy a given condition, with short-circuiting behaviour as soon as it finds one. -=head2 The 'all' feature +=head2 The 'keyword_all' feature B: This feature is still experimental and the implementation may change or be removed 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::all"; + no warnings "experimental::keyword_all"; This feature enables the L|perlfunc/all BLOCK LIST> operator keyword. This allow testing whether all of the values in a list satisfy a given condition, with short-circuiting behaviour as soon as it finds one that does not. -B remember that this enables one specific feature whose name is C; -it does not enable all of the features. This is not C. -For that, see the section below. - =head1 FEATURE BUNDLES It's possible to load multiple features together, using diff --git a/regen/keywords.pl b/regen/keywords.pl index 9379e57712e8..c01d4ba5e1bd 100755 --- a/regen/keywords.pl +++ b/regen/keywords.pl @@ -36,6 +36,7 @@ # If this hash changes, make sure the equivalent hash in # lib/B/Deparse.pm (%feature_keywords) is also updated. my %feature_kw = ( + # keyword => feature name state => 'state', say => 'say', given => 'switch', @@ -56,8 +57,8 @@ method => 'class', ADJUST => 'class', __CLASS__ => 'class', - any => 'any', - all => 'all', + any => 'keyword_any', + all => 'keyword_all', ); my %pos = map { ($_ => 1) } @{$by_strength{'+'}}; diff --git a/regen/warnings.pl b/regen/warnings.pl index 04fc0562f217..d518b4cc95cd 100644 --- a/regen/warnings.pl +++ b/regen/warnings.pl @@ -16,7 +16,7 @@ # # This script is normally invoked from regen.pl. -$VERSION = '1.73'; +$VERSION = '1.74'; BEGIN { require './regen/regen_lib.pl'; @@ -157,9 +157,9 @@ BEGIN [ 5.035, DEFAULT_ON], 'experimental::class' => [ 5.037, DEFAULT_ON ], - 'experimental::any' => + 'experimental::keyword_any' => [ 5.041, DEFAULT_ON ], - 'experimental::all' => + 'experimental::keyword_all' => [ 5.041, DEFAULT_ON ], }], diff --git a/t/lib/croak/op b/t/lib/croak/op index cdd641db9417..20b47f4e177e 100644 --- a/t/lib/croak/op +++ b/t/lib/croak/op @@ -328,16 +328,16 @@ EXPECT Downgrading a use VERSION declaration to below v5.11 is not permitted at - line 3. ######## # any with deferred LIST expression -use feature 'any'; -no warnings 'experimental::any'; +use feature 'keyword_any'; +no warnings 'experimental::keyword_any'; any length, qw( a b c ) EXPECT syntax error at - line 4, near "any length" Execution of - aborted due to compilation errors. ######## # all with deferred LIST expression -use feature 'all'; -no warnings 'experimental::all'; +use feature 'keyword_all'; +no warnings 'experimental::keyword_all'; all length, qw( a b c ) EXPECT syntax error at - line 4, near "all length" diff --git a/t/op/any_all.t b/t/op/any_all.t index aac214b488c8..e9d11fcb96e1 100644 --- a/t/op/any_all.t +++ b/t/op/any_all.t @@ -6,8 +6,8 @@ BEGIN { set_up_inc('../lib'); } -use feature qw( any all ); -no warnings qw( experimental::any experimental::all ); +use feature qw( keyword_any keyword_all ); +no warnings qw( experimental::keyword_any experimental::keyword_all ); # Basic true/false testing ok( (any { $_ > 10 } 1 .. 20), 'list contains a value above ten' ); diff --git a/toke.c b/toke.c index 172d0d5bf586..975a0a45a48d 100644 --- a/toke.c +++ b/toke.c @@ -7973,7 +7973,7 @@ yyl_word_or_keyword(pTHX_ char *s, STRLEN len, I32 key, I32 orig_keyword, struct case KEY_all: Perl_ck_warner_d(aTHX_ - packWARN(WARN_EXPERIMENTAL__ALL), "all is experimental"); + packWARN(WARN_EXPERIMENTAL__KEYWORD_ALL), "all is experimental"); BLKLOP(OP_ALLSTART); case KEY_and: @@ -7983,7 +7983,7 @@ yyl_word_or_keyword(pTHX_ char *s, STRLEN len, I32 key, I32 orig_keyword, struct case KEY_any: Perl_ck_warner_d(aTHX_ - packWARN(WARN_EXPERIMENTAL__ANY), "any is experimental"); + packWARN(WARN_EXPERIMENTAL__KEYWORD_ANY), "any is experimental"); BLKLOP(OP_ANYSTART); case KEY_atan2: diff --git a/warnings.h b/warnings.h index 841839be903e..bbe92dfe50f8 100644 --- a/warnings.h +++ b/warnings.h @@ -160,8 +160,8 @@ /* Warnings Categories added in Perl 5.041 */ -#define WARN_EXPERIMENTAL__ALL 78 -#define WARN_EXPERIMENTAL__ANY 79 +#define WARN_EXPERIMENTAL__KEYWORD_ALL 78 +#define WARN_EXPERIMENTAL__KEYWORD_ANY 79 #define WARNsize 20 #define WARN_ALLstring "\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125" #define WARN_NONEstring "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" @@ -354,8 +354,8 @@ category parameters passed. =for apidoc Amnh||WARN_EXPERIMENTAL__CLASS =for apidoc Amnh||WARN_DEPRECATED__MISSING_IMPORT_CALLED_WITH_ARGS =for apidoc Amnh||WARN_DEPRECATED__SUBSEQUENT_USE_VERSION -=for apidoc Amnh||WARN_EXPERIMENTAL__ALL -=for apidoc Amnh||WARN_EXPERIMENTAL__ANY +=for apidoc Amnh||WARN_EXPERIMENTAL__KEYWORD_ALL +=for apidoc Amnh||WARN_EXPERIMENTAL__KEYWORD_ANY =cut */