Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

goto

瀏覽次數:0 次
跳到第一則未讀訊息

Larry Wall

未讀,
2006年1月31日 下午5:49:512006/1/31
收件者:perl6-l...@perl.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

0 則新訊息