develooper Front page | perl.perl6.language | Postings from January 2006

goto

From:
Larry Wall
Date:
January 31, 2006 14:50
Subject:
goto
Message ID:
20060131224950.GA24464@wall.org
Just added the following to S04:

    =head1 The goto statement

    In addition to C<next>, C<last>, and C<redo>, Perl 6 also supports
    C<goto>.  As with ordinary loop controls, the label is searched for
    first lexically within the current subroutine, then dynamically outside
    of it.  Unlike with loop controls, however, scanning a scope includes
    a scan of any lexical scopes included within the current candidate
    scope.  As in Perl 5, it is possible to C<goto> into a lexical scope,
    but only for lexical scopes that require no special initialization
    of parameters.  (Initialization of ordinary variables does not
    count--presumably the presence of a label will prevent code-movement
    optimizations past the label.)  So, for instance, it's always possible
    to goto into the next case of a C<when> or into either the "then"
    or "else" branch of a conditional.  You may not go into a C<given>
    or a C<for>, though, because that would bypass a formal parameter
    binding (not to mention list generation in the case of C<for>).
    (Note: the implicit default binding of an outer $_ to an inner $_
    can be emulated for a bare block, so that doesn't fall under the
    prohibition on bypassing formal binding.)

Larry



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