From: Rafael Garcia-Suarez Date: Wed, 3 May 2006 22:01:41 +0000 (+0000) Subject: Add "state" feature X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=712d05cf9bbf674929d5e38c5bb989d87c51f19b;p=p5sagit%2Fp5-mst-13.2.git Add "state" feature p4raw-id: //depot/perl@28087 --- diff --git a/lib/feature.pm b/lib/feature.pm index d4975e4..240d46d 100644 --- a/lib/feature.pm +++ b/lib/feature.pm @@ -1,6 +1,6 @@ package feature; -our $VERSION = '1.00'; +our $VERSION = '1.01'; # (feature name) => (internal name, used in %^H) my %feature = ( @@ -8,10 +8,11 @@ my %feature = ( "~~" => "feature_~~", say => "feature_say", err => "feature_err", + state => "feature_state", ); my %feature_bundle = ( - "5.10" => [qw(switch ~~ say err)], + "5.10" => [qw(switch ~~ say err state)], ); @@ -81,13 +82,18 @@ operator from here to the end of the enclosing BLOCK. C is a low-precedence variant of the C operator: see C for details. +=head2 the 'state' feature + +C tells the compiler to enable C +variables from here to the end of the enclosing BLOCK. + =head1 FEATURE BUNDLES It's possible to load a whole slew of features in one go, using a I. The name of a feature bundle is prefixed with a colon, to distinguish it from an actual feature. At present, the only feature bundle is C, which is equivalent -to C. +to C. =cut diff --git a/perl_keyword.pl b/perl_keyword.pl index 636f6a9..b2e9e34 100644 --- a/perl_keyword.pl +++ b/perl_keyword.pl @@ -45,6 +45,8 @@ my %feature_kw = ( say => 'say', err => 'err', + + state => 'state', ); my %pos = map { ($_ => 1) } @pos; diff --git a/t/op/state.t b/t/op/state.t index 987cf6e..3b68879 100644 --- a/t/op/state.t +++ b/t/op/state.t @@ -7,6 +7,7 @@ BEGIN { } use strict; +use feature "state"; plan tests => 19; diff --git a/toke.c b/toke.c index 3700e34..23f801e 100644 --- a/toke.c +++ b/toke.c @@ -8144,7 +8144,7 @@ Perl_keyword (pTHX_ const char *name, I32 len) if (name[3] == 't' && name[4] == 'e') { /* state */ - return KEY_state; + return (FEATURE_IS_ENABLED("state") ? KEY_state : 0); } goto unknown;