Skip to content

Commit a335953

Browse files
committed
tell how return relates to outer scopes
1 parent 0afdeea commit a335953

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/Language/control.pod6

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,12 @@ exception L<X::TypeCheck::Return|/type/X::TypeCheck::Return> is thrown. If it
687687
passes a control exception is raised and can be caught with
688688
L<CONTROL|/language/phasers#CONTROL>.
689689
690+
Any C<return> in a block is tied to the outer lexical scope of that block.
691+
Please note that a C<return> in the root of a package will fail at runtime. A
692+
C<return> in a block that is evaluated lazily (e.g. inside C<map>) may find the
693+
outer lexical routine gone by the time the block is executed. In almost any
694+
case C<last> is the better alternative.
695+
690696
=comment TODO add link to section in /language/function that shows how return values are produces/handled
691697
692698
=head1 X<return-rw|control flow>

0 commit comments

Comments
 (0)