Skip to content

Commit

Permalink
Create a default-on 'format_vars' feature
Browse files Browse the repository at this point in the history
  • Loading branch information
leonerd committed May 4, 2021
1 parent acd998d commit 7f31b17
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 51 deletions.
37 changes: 25 additions & 12 deletions feature.h
Expand Up @@ -18,18 +18,19 @@
#define FEATURE_MYREF_BIT 0x0008
#define FEATURE_EVALBYTES_BIT 0x0010
#define FEATURE_FC_BIT 0x0020
#define FEATURE_INDIRECT_BIT 0x0040
#define FEATURE_ISA_BIT 0x0080
#define FEATURE_MULTIDIMENSIONAL_BIT 0x0100
#define FEATURE_POSTDEREF_QQ_BIT 0x0200
#define FEATURE_REFALIASING_BIT 0x0400
#define FEATURE_SAY_BIT 0x0800
#define FEATURE_SIGNATURES_BIT 0x1000
#define FEATURE_STATE_BIT 0x2000
#define FEATURE_SWITCH_BIT 0x4000
#define FEATURE_TRY_BIT 0x8000
#define FEATURE_UNIEVAL_BIT 0x10000
#define FEATURE_UNICODE_BIT 0x20000
#define FEATURE_FORMAT_VARS_BIT 0x0040
#define FEATURE_INDIRECT_BIT 0x0080
#define FEATURE_ISA_BIT 0x0100
#define FEATURE_MULTIDIMENSIONAL_BIT 0x0200
#define FEATURE_POSTDEREF_QQ_BIT 0x0400
#define FEATURE_REFALIASING_BIT 0x0800
#define FEATURE_SAY_BIT 0x1000
#define FEATURE_SIGNATURES_BIT 0x2000
#define FEATURE_STATE_BIT 0x4000
#define FEATURE_SWITCH_BIT 0x8000
#define FEATURE_TRY_BIT 0x10000
#define FEATURE_UNIEVAL_BIT 0x20000
#define FEATURE_UNICODE_BIT 0x40000

#define FEATURE_BUNDLE_DEFAULT 0
#define FEATURE_BUNDLE_510 1
Expand Down Expand Up @@ -131,6 +132,13 @@
FEATURE_IS_ENABLED_MASK(FEATURE___SUB___BIT)) \
)

#define FEATURE_FORMAT_VARS_IS_ENABLED \
( \
CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_527 \
|| (CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
FEATURE_IS_ENABLED_MASK(FEATURE_FORMAT_VARS_BIT)) \
)

#define FEATURE_REFALIASING_IS_ENABLED \
( \
CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
Expand Down Expand Up @@ -277,6 +285,11 @@ S_magic_sethint_feature(pTHX_ SV *keysv, const char *keypv, STRLEN keylen,
mask = FEATURE_FC_BIT;
break;
}
else if (keylen == sizeof("feature_format_vars")-1
&& memcmp(subf+1, "ormat_vars", keylen - sizeof("feature_")) == 0) {
mask = FEATURE_FORMAT_VARS_BIT;
break;
}
return;

case 'i':
Expand Down
86 changes: 50 additions & 36 deletions lib/feature.pm
Expand Up @@ -5,7 +5,7 @@

package feature;

our $VERSION = '1.64';
our $VERSION = '1.65';

our %feature = (
fc => 'feature_fc',
Expand All @@ -19,6 +19,7 @@ our %feature = (
evalbytes => 'feature_evalbytes',
signatures => 'feature_signatures',
current_sub => 'feature___SUB__',
format_vars => 'feature_format_vars',
refaliasing => 'feature_refaliasing',
postderef_qq => 'feature_postderef_qq',
unicode_eval => 'feature_unieval',
Expand All @@ -29,13 +30,13 @@ our %feature = (
);

our %feature_bundle = (
"5.10" => [qw(bareword_filehandles indirect multidimensional say state switch)],
"5.11" => [qw(bareword_filehandles indirect multidimensional say state switch unicode_strings)],
"5.15" => [qw(bareword_filehandles current_sub evalbytes fc indirect multidimensional say state switch unicode_eval unicode_strings)],
"5.23" => [qw(bareword_filehandles current_sub evalbytes fc indirect multidimensional postderef_qq say state switch unicode_eval unicode_strings)],
"5.27" => [qw(bareword_filehandles bitwise current_sub evalbytes fc indirect multidimensional postderef_qq say state switch unicode_eval unicode_strings)],
"all" => [qw(bareword_filehandles bitwise current_sub declared_refs evalbytes fc indirect isa multidimensional postderef_qq refaliasing say signatures state switch try unicode_eval unicode_strings)],
"default" => [qw(bareword_filehandles indirect multidimensional)],
"5.10" => [qw(bareword_filehandles format_vars indirect multidimensional say state switch)],
"5.11" => [qw(bareword_filehandles format_vars indirect multidimensional say state switch unicode_strings)],
"5.15" => [qw(bareword_filehandles current_sub evalbytes fc format_vars indirect multidimensional say state switch unicode_eval unicode_strings)],
"5.23" => [qw(bareword_filehandles current_sub evalbytes fc format_vars indirect multidimensional postderef_qq say state switch unicode_eval unicode_strings)],
"5.27" => [qw(bareword_filehandles bitwise current_sub evalbytes fc format_vars indirect multidimensional postderef_qq say state switch unicode_eval unicode_strings)],
"all" => [qw(bareword_filehandles bitwise current_sub declared_refs evalbytes fc format_vars indirect isa multidimensional postderef_qq refaliasing say signatures state switch try unicode_eval unicode_strings)],
"default" => [qw(bareword_filehandles format_vars indirect multidimensional)],
);

$feature_bundle{"5.12"} = $feature_bundle{"5.11"};
Expand Down Expand Up @@ -429,6 +430,19 @@ C<try> are caught by executing the body of the C<catch> block.
For more information, see L<perlsyn/"Try Catch Exception Handling">.
=head2 The 'format_vars' feature.
This feature enables the punctuation variables that affect the operation of
formats. It is enabled by default, but can be turned off to disallow the use
of these variables.
$^A $^L $% $- $: $= $^ $~
This is provided for the possible future expansion of the language, which may
wish to use variable syntax including these characters, but currently cannot
due to its collision with these little-used variables. By disabling this
feature it permits these as a possible future expansion.
=head1 FEATURE BUNDLES
It's possible to load multiple features together, using
Expand All @@ -442,64 +456,64 @@ The following feature bundles are available:
bundle features included
--------- -----------------
:default indirect multidimensional
bareword_filehandles
bareword_filehandles format_vars
:5.10 bareword_filehandles indirect
:5.10 bareword_filehandles format_vars indirect
multidimensional say state switch
:5.12 bareword_filehandles indirect
:5.12 bareword_filehandles format_vars indirect
multidimensional say state switch
unicode_strings
:5.14 bareword_filehandles indirect
:5.14 bareword_filehandles format_vars indirect
multidimensional say state switch
unicode_strings
:5.16 bareword_filehandles current_sub evalbytes
fc indirect multidimensional say state
switch unicode_eval unicode_strings
fc format_vars indirect multidimensional say
state switch unicode_eval unicode_strings
:5.18 bareword_filehandles current_sub evalbytes
fc indirect multidimensional say state
switch unicode_eval unicode_strings
fc format_vars indirect multidimensional say
state switch unicode_eval unicode_strings
:5.20 bareword_filehandles current_sub evalbytes
fc indirect multidimensional say state
switch unicode_eval unicode_strings
fc format_vars indirect multidimensional say
state switch unicode_eval unicode_strings
:5.22 bareword_filehandles current_sub evalbytes
fc indirect multidimensional say state
switch unicode_eval unicode_strings
fc format_vars indirect multidimensional say
state switch unicode_eval unicode_strings
:5.24 bareword_filehandles current_sub evalbytes
fc indirect multidimensional postderef_qq
say state switch unicode_eval
fc format_vars indirect multidimensional
postderef_qq say state switch unicode_eval
unicode_strings
:5.26 bareword_filehandles current_sub evalbytes
fc indirect multidimensional postderef_qq
say state switch unicode_eval
fc format_vars indirect multidimensional
postderef_qq say state switch unicode_eval
unicode_strings
:5.28 bareword_filehandles bitwise current_sub
evalbytes fc indirect multidimensional
postderef_qq say state switch unicode_eval
unicode_strings
evalbytes fc format_vars indirect
multidimensional postderef_qq say state
switch unicode_eval unicode_strings
:5.30 bareword_filehandles bitwise current_sub
evalbytes fc indirect multidimensional
postderef_qq say state switch unicode_eval
unicode_strings
evalbytes fc format_vars indirect
multidimensional postderef_qq say state
switch unicode_eval unicode_strings
:5.32 bareword_filehandles bitwise current_sub
evalbytes fc indirect multidimensional
postderef_qq say state switch unicode_eval
unicode_strings
evalbytes fc format_vars indirect
multidimensional postderef_qq say state
switch unicode_eval unicode_strings
:5.34 bareword_filehandles bitwise current_sub
evalbytes fc indirect multidimensional
postderef_qq say state switch unicode_eval
unicode_strings
evalbytes fc format_vars indirect
multidimensional postderef_qq say state
switch unicode_eval unicode_strings
The C<:default> bundle represents the feature set that is enabled before
any C<use feature> or C<no feature> declaration.
Expand Down
20 changes: 17 additions & 3 deletions regen/feature.pl
Expand Up @@ -41,6 +41,7 @@ BEGIN
multidimensional => 'multidimensional',
bareword_filehandles => 'bareword_filehandles',
try => 'try',
format_vars => 'format_vars',
);

# NOTE: If a feature is ever enabled in a non-contiguous range of Perl
Expand All @@ -50,15 +51,15 @@ BEGIN
# 5.odd implies the next 5.even, but an explicit 5.even can override it.

# features bundles
use constant V5_9_5 => sort qw{say state switch indirect multidimensional bareword_filehandles};
use constant V5_9_5 => sort qw{say state switch indirect multidimensional bareword_filehandles format_vars};
use constant V5_11 => sort ( +V5_9_5, qw{unicode_strings} );
use constant V5_15 => sort ( +V5_11, qw{unicode_eval evalbytes current_sub fc} );
use constant V5_23 => sort ( +V5_15, qw{postderef_qq} );
use constant V5_27 => sort ( +V5_23, qw{bitwise} );

my %feature_bundle = (
all => [ sort keys %feature ],
default => [ qw{indirect multidimensional bareword_filehandles} ],
default => [ qw{indirect multidimensional bareword_filehandles format_vars} ],
# using 5.9.5 features bundle
"5.9.5" => [ +V5_9_5 ],
"5.10" => [ +V5_9_5 ],
Expand Down Expand Up @@ -478,7 +479,7 @@ sub longest {
__END__
package feature;
our $VERSION = '1.64';
our $VERSION = '1.65';
FEATURES
Expand Down Expand Up @@ -835,6 +836,19 @@ =head2 The 'try' feature.
For more information, see L<perlsyn/"Try Catch Exception Handling">.
=head2 The 'format_vars' feature.
This feature enables the punctuation variables that affect the operation of
formats. It is enabled by default, but can be turned off to disallow the use
of these variables.
$^A $^L $% $- $: $= $^ $~
This is provided for the possible future expansion of the language, which may
wish to use variable syntax including these characters, but currently cannot
due to its collision with these little-used variables. By disabling this
feature it permits these as a possible future expansion.
=head1 FEATURE BUNDLES
It's possible to load multiple features together, using
Expand Down

0 comments on commit 7f31b17

Please sign in to comment.