Change 28491 by [EMAIL PROTECTED] on 2006/07/06 13:36:57

        Mention state variables in perldiag. Add switch-related keywords
        in the keyword listing section in perlfunc. Add a summary of
        C<state> in perlfunc. Fix a typo in the synopsis for C<our>.
        Don't say that C<my $_> is illegal in perlsub.

Affected files ...

... //depot/perl/pod/perldiag.pod#444 edit
... //depot/perl/pod/perlfunc.pod#526 edit
... //depot/perl/pod/perlsub.pod#63 edit

Differences ...

==== //depot/perl/pod/perldiag.pod#444 (text) ====
Index: perl/pod/perldiag.pod
--- perl/pod/perldiag.pod#443~28382~    2006-06-12 05:08:54.000000000 -0700
+++ perl/pod/perldiag.pod       2006-07-06 06:36:57.000000000 -0700
@@ -1422,13 +1422,18 @@
 static variable. Since we intend to fix this bug, we don't want people
 relying on this behavior. You can achieve a similar static effect by
 declaring the variable in a separate block outside the function, eg
-    
+
     sub f { my $x if 0; return $x++ }
 
 becomes
 
     { my $x; sub f { return $x++ } }
 
+Beginning with perl 5.9.4, you can also use C<state> variables to
+have lexicals that are initialized only once (see L<feature>):
+
+    sub f { state $x; return $x++ }
+
 =item DESTROY created new reference to dead object '%s'
 
 (F) A DESTROY() method created a new reference to the object which is

==== //depot/perl/pod/perlfunc.pod#526 (text) ====
Index: perl/pod/perlfunc.pod
--- perl/pod/perlfunc.pod#525~28473~    2006-07-03 11:09:01.000000000 -0700
+++ perl/pod/perlfunc.pod       2006-07-06 06:36:57.000000000 -0700
@@ -158,19 +158,23 @@
 
 =item Keywords related to switch
 
-C<break>, C<continue>
+C<break>, C<continue>, C<given>, C<when>, C<default>
 
 (These are only available if you enable the "switch" feature.
 See L<feature> and L<perlsyn/"Switch statements">.)
 
 =item Keywords related to scoping
 
-C<caller>, C<import>, C<local>, C<my>, C<our>, C<package>, C<use>
+C<caller>, C<import>, C<local>, C<my>, C<our>, C<state>, C<package>,
+C<use>
+
+(C<state> is only available if the "state" feature is enabled. See
+L<feature>.)
 
 =item Miscellaneous functions
 
-C<defined>, C<dump>, C<eval>, C<formline>, C<local>, C<my>, C<our>, C<reset>,
-C<scalar>, C<undef>, C<wantarray>
+C<defined>, C<dump>, C<eval>, C<formline>, C<local>, C<my>, C<our>,
+C<state>, C<reset>, C<scalar>, C<undef>, C<wantarray>
 
 =item Functions for processes and process groups
 X<process> X<pid> X<process id>
@@ -229,8 +233,10 @@
 
 C<abs>, C<bless>, C<chomp>, C<chr>, C<exists>, C<formline>, C<glob>,
 C<import>, C<lc>, C<lcfirst>, C<lock>, C<map>, C<my>, C<no>, C<our>,
+C<state>,
 C<prototype>, C<qr>, C<qw>, C<qx>, C<readline>, C<readpipe>, C<ref>,
-C<sub>*, C<sysopen>, C<tie>, C<tied>, C<uc>, C<ucfirst>, C<untie>, C<use>
+C<sub>*, C<sysopen>, C<tie>, C<tied>, C<uc>, C<ucfirst>, C<untie>, C<use>,
+C<break>, C<continue>, C<given>, C<when>, C<default>
 
 * - C<sub> was a keyword in perl4, but in perl5 it is an
 operator, which can be used in expressions.
@@ -3429,7 +3435,7 @@
 =item our EXPR
 X<our> X<global>
 
-=item our EXPR TYPE
+=item our TYPE EXPR
 
 =item our EXPR : ATTRS
 
@@ -5957,6 +5963,23 @@
 about the C<S_*> constants.  To get status info for a symbolic link
 instead of the target file behind the link, use the C<lstat> function.
 
+=item state EXPR
+X<state>
+
+=item state TYPE EXPR
+
+=item state EXPR : ATTRS
+
+=item state TYPE EXPR : ATTRS
+
+C<state> declares a lexically scoped variable, just like C<my> does.
+However, those variables will be initialized only once, contrary to
+lexical variables that are reinitialized each time their enclosing block
+is entered.
+
+C<state> variables are only enabled when the C<feature 'state'> pragma is
+in effect.  See L<feature>.
+
 =item study SCALAR
 X<study>
 

==== //depot/perl/pod/perlsub.pod#63 (text) ====
Index: perl/pod/perlsub.pod
--- perl/pod/perlsub.pod#62~26073~      2005-11-10 02:52:51.000000000 -0800
+++ perl/pod/perlsub.pod        2006-07-06 06:36:57.000000000 -0700
@@ -394,7 +394,6 @@
 allowed to try to make a package variable (or other global) lexical:
 
     my $pack::var;     # ERROR!  Illegal syntax
-    my $_;             # also illegal (currently)
 
 In fact, a dynamic variable (also known as package or global variables)
 are still accessible using the fully qualified C<::> notation even while a
End of Patch.

Reply via email to