Changeset 23241

Show
Ignore:
Timestamp:
01/31/06 23:25:25 (3 years ago)
Author:
larry
Message:

Documented goto requirements. (Basically same as Perl 5.)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • doc/trunk/design/syn/S04.pod

    r23234 r23241  
    1313  Maintainer: Larry Wall <larry@wall.org> 
    1414  Date: 19 Aug 2004 
    15   Last Modified: 04 Jan 2006 
     15  Last Modified: 31 Jan 2006 
    1616  Number: 4 
    17   Version: 7 
     17  Version: 8 
    1818 
    1919This document summarizes Apocalypse 4, which covers the block and 
     
    404404in the current sub was implicit.  For Perl 6 we have to make this 
    405405preference explicit.) 
     406 
     407=head1 The goto statement 
     408 
     409In addition to C<next>, C<last>, and C<redo>, Perl 6 also supports 
     410C<goto>.  As with ordinary loop controls, the label is searched for 
     411first lexically within the current subroutine, then dynamically outside 
     412of it.  Unlike with loop controls, however, scanning a scope includes 
     413a scan of any lexical scopes included within the current candidate 
     414scope.  As in Perl 5, it is possible to C<goto> into a lexical scope, 
     415but only for lexical scopes that require no special initialization 
     416of parameters.  (Initialization of ordinary variables does not 
     417count--presumably the presence of a label will prevent code-movement 
     418optimizations past the label.)  So, for instance, it's always possible 
     419to goto into the next case of a C<when> or into either the "then" 
     420or "else" branch of a conditional.  You may not go into a C<given> 
     421or a C<for>, though, because that would bypass a formal parameter 
     422binding (not to mention list generation in the case of C<for>). 
     423(Note: the implicit default binding of an outer $_ to an inner $_ 
     424can be emulated for a bare block, so that doesn't fall under the 
     425prohibition on bypassing formal binding.) 
    406426 
    407427=head1 Exceptions