Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
gather/take is lexotic with dynamic fallback
We have to allow for implementations and libraries to use gather/take
internally.  To preserve the sanity of the user in such cases,
we need gather/take to behave lexotically, so that if you use take
in the lexical scope of a gather, it always goes to *that* gather,
even if the take is inside a closure that is passed into the scope
of another gather.
  • Loading branch information
TimToady committed Jun 23, 2011
1 parent d885007 commit b4e7bc1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions S04-control.pod
Expand Up @@ -13,8 +13,8 @@ Synopsis 4: Blocks and Statements

Created: 19 Aug 2004

Last Modified: 18 Jun 2011
Version: 105
Last Modified: 23 Jun 2011
Version: 106

This document summarizes Apocalypse 4, which covers the block and
statement syntax of Perl.
Expand Down Expand Up @@ -703,7 +703,11 @@ block in sink (void) context; its return value is instead specified by calling
the C<take> list prefix operator one or more times within the dynamic scope of
the C<gather>. The C<take> function's signature is like that of C<return>;
while having the syntax of a list operator, it merely returns a single item
or "argument" (see L<S02> for definition).
or "argument" (see L<S02> for definition). The C<take> function is lexotic
if there is a visible outer C<gather>, but falls back to purely dynamic if not.
(Use of the dynamic semantics cannot be guaranteed to be portable when passing
closures into some other construct, either built-in or not, since implementations
of libraries and of Perl itself may use C<gather>/C<take> internally.)

If you take multiple items in a comma list (since it is, after all, a list
operator), they will be wrapped up in a C<Parcel> object for return as the
Expand Down

0 comments on commit b4e7bc1

Please sign in to comment.