develooper Front page | perl.perl5.porters | Postings from March 2003

[PATCH] perlsub.pod and perlsyn.pod: better organise scoping info for modifiers

Thread Next
From:
Martien Verbruggen
Date:
March 15, 2003 00:45
Subject:
[PATCH] perlsub.pod and perlsyn.pod: better organise scoping info for modifiers
Message ID:
slrnb750k3.j8t.mgjv@martien.heliotrope.home
Currently the only information about what happens with contructs like
this:

my $x = $_ for (@array);

is documented in perlsub in a note, which is hardly the right place for
it. The section in perlsyn which defines the statement modifiers has
nothing on it.

This patch moves the note from perlsub to perlsyn, and puts a reference
to the perlsyn section in perlsub.


Regards,
Martien


diff -r -c ../devperl/pod/perlsub.pod ./pod/perlsub.pod
*** ../devperl/pod/perlsub.pod	2003-02-15 18:27:01.000000000 +1100
--- ./pod/perlsub.pod	2003-03-15 12:21:39.000000000 +1100
***************
*** 325,338 ****
  
  the scope of $answer extends from its declaration through the rest
  of that conditional, including any C<elsif> and C<else> clauses, 
! but not beyond it.
! 
! B<NOTE:> The behaviour of a C<my> statement modified with a statement
! modifier conditional or loop construct (e.g. C<my $x if ...>) is
! B<undefined>.  The value of the C<my> variable may be C<undef>, any
! previously assigned value, or possibly anything else.  Don't rely on
! it.  Future versions of perl might do something different from the
! version of perl you try it out on.  Here be dragons.
  
  The C<foreach> loop defaults to scoping its index variable dynamically
  in the manner of C<local>.  However, if the index variable is
--- 325,332 ----
  
  the scope of $answer extends from its declaration through the rest
  of that conditional, including any C<elsif> and C<else> clauses, 
! but not beyond it.  See L<perlsyn/"Simple statements"> for information
! on the scope of variables in statements with modifiers.
  
  The C<foreach> loop defaults to scoping its index variable dynamically
  in the manner of C<local>.  However, if the index variable is
diff -r -c ../devperl/pod/perlsyn.pod ./pod/perlsyn.pod
*** ../devperl/pod/perlsyn.pod	2003-01-21 14:06:22.000000000 +1100
--- ./pod/perlsyn.pod	2003-03-15 12:21:42.000000000 +1100
***************
*** 134,139 ****
--- 134,147 ----
  	    } while $x++ <= $z;
      }
  
+ B<NOTE:> The behaviour of a C<my> statement modified with a statement
+ modifier conditional or loop construct (e.g. C<my $x if ...>) is
+ B<undefined>.  The value of the C<my> variable may be C<undef>, any
+ previously assigned value, or possibly anything else.  Don't rely on
+ it.  Future versions of perl might do something different from the
+ version of perl you try it out on.  Here be dragons.
+ 
+ 
  =head2 Compound statements
  
  In Perl, a sequence of statements that defines a scope is called a block.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About