Skip to content

Commit

Permalink
deprecate the ':all' feature bundle
Browse files Browse the repository at this point in the history
As discussed in Perl/PPCs#60, `:all` is very unlikely to be useful.

Since it will enable all features a future Perl might support, it will
also enable some that might be incompatible with the code as written
(see `bitwise`, for example, which changes the meaning of the existing
bitwise operators).

With the addition of "negative" features in v5.32, `:all` became even
less useful, since it would re-enable features deemed undesirable in
modern Perl.

As this point in time, `:all` is effectively a footgun.

If the keyword `all` (from PPC0027) is added as a feature, there's an
extra risk of confusion between `use feature 'all'` and `use feature ':all'`.

This patch makes `:all` warn. We should consider removing that bundle
entirely in the future.
  • Loading branch information
book committed Dec 4, 2024
1 parent 30a8f95 commit 849f151
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
9 changes: 8 additions & 1 deletion lib/feature.pm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ L<XXX> has been upgraded from version A.xx to B.yy.

XXX If there was something important to note about this change, include that here.

=item *

L<feature> has been upgraded from version 1.89 to 1.93.

The C<:all> feature bundle now warns, suggesting you should not use it.

=back

=head2 Removed Modules and Pragmata
Expand Down
9 changes: 8 additions & 1 deletion regen/feature.pl
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ sub longest {

__END__
package feature;
our $VERSION = '1.92';
our $VERSION = '1.93';
FEATURES
Expand Down Expand Up @@ -1175,6 +1175,8 @@ sub __common {
my $name = shift;
if (substr($name, 0, 1) eq ":") {
my $v = substr($name, 1);
carp('Feature bundle ":all" is deprecated and should not be used')
if $v eq 'all';
if (!exists $feature_bundle{$v}) {
$v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/;
if (!exists $feature_bundle{$v}) {
Expand Down Expand Up @@ -1215,6 +1217,11 @@ sub unknown_feature_bundle {
$feature, $^V));
}
sub carp {
require Carp;
Carp::carp(@_);
}
sub croak {
require Carp;
Carp::croak(@_);
Expand Down
1 change: 0 additions & 1 deletion t/comp/require.t
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ BEGIN {
my @params = (
'use v5.37',
'use feature ":5.38"',
'use feature ":all"',
'use feature "module_true"',
'no feature "module_true"',
'',
Expand Down
1 change: 1 addition & 0 deletions t/lib/feature/bundle
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Assigning non-zero to $[ is no longer possible at - line 5.
no feature ':all'; # turns array_base (and everything else) off
$[ = 1;
EXPECT
Feature bundle ":all" is deprecated and should not be used at - line 2.
Assigning non-zero to $[ is no longer possible at - line 3.
########
# NAME $^H accidentally enabling all features
Expand Down
6 changes: 3 additions & 3 deletions t/op/lexsub.t
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ like runperl(
# This used to fail an assertion, but only as a standalone script
is runperl(switches => ['-lXMfeature=:all'],
prog => 'state sub x {}; undef &x; print defined &x',
stderr => 1), "\n", 'undefining state sub';
stderr => 1), "Feature bundle \":all\" is deprecated and should not be used at -e line 0.\n\n", 'undefining state sub';
{
state sub x { is +(caller 0)[3], 'x', 'state sub name in caller' }
x
Expand Down Expand Up @@ -475,7 +475,7 @@ is runperl(switches => ['-lXMfeature=:all'],
x()
}
x()',
stderr => 1), "42\n",
stderr => 1), "Feature bundle \":all\" is deprecated and should not be used at -e line 0.\n42\n",
'closure behaviour of state sub in predeclared package sub';

# -------------------- my -------------------- #
Expand Down Expand Up @@ -830,7 +830,7 @@ pass "pad taking ownership once more of packagified my-sub";
# This used to fail an assertion, but only as a standalone script
is runperl(switches => ['-lXMfeature=:all'],
prog => 'my sub x {}; undef &x; print defined &x',
stderr => 1), "\n", 'undefining my sub';
stderr => 1), "Feature bundle \":all\" is deprecated and should not be used at -e line 0.\n\n", 'undefining my sub';
{
my sub x { is +(caller 0)[3], 'x', 'my sub name in caller' }
x
Expand Down

0 comments on commit 849f151

Please sign in to comment.