Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update example and error message
  • Loading branch information
gfldex committed Jun 20, 2016
1 parent 5ac6d7b commit ffb9ce7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
38 changes: 19 additions & 19 deletions doc/Language/phasers.pod
Expand Up @@ -171,13 +171,13 @@ teardown usually want to happen in the opposite order from each other.
=head1 Program Execution Phasers
=head2 BEGIN
=head2 X<BEGIN|BEGIN (phasers)>
Runs at compile time, as soon as possible, only runs once.
Can have a return value that is provided even in later phases.
=head2 CHECK
=head2 X<CHECK|CHECK (phasers)>
Runs at compile time, As late as possible, only runs once.
Expand All @@ -187,7 +187,7 @@ Code that is generated at run time can still fire off C<CHECK> and C<INIT>
phasers, though of course those phasers can't do things that would require
travel back in time. You need a wormhole for that.
=head2 LINK
=head2 X<LINK|LINK (phasers)>
Runs at link time, As late as possible, only runs once.
Expand All @@ -196,7 +196,7 @@ Can have a return value that is provided even in later phases.
The compiler is free to ignore C<LINK> phasers compiled at run time since
they're too late for the application-wide linking decisions.
=head2 INIT
=head2 X<INIT|INIT (phasers)>
Runs after compilation during main execution, as soon as possible, only runs
once.
Expand All @@ -214,7 +214,7 @@ travel back in time. You need a wormhole for that.
An C<INIT> only runs once for all copies of a cloned closure.
=head2 END
=head2 X<END|END (phasers)>
Runs after compilation during main execution, as late as possible, only runs
once.
Expand Down Expand Up @@ -246,7 +246,7 @@ All of these phaser blocks can see any previously declared lexical variables,
even if those variables have not been elaborated yet when the closure is
invoked (in which case the variables evaluate to an undefined value.)
=head2 ENTER
=head2 X<ENTER|ENTER (phasers)>
Runs at every block entry time, repeats on loop blocks.
Expand All @@ -255,7 +255,7 @@ Can have a return value that is provided even in later phases.
An exception thrown from an C<ENTER> phaser will abort the C<ENTER> queue, but
one thrown from a C<LEAVE> phaser will not.
=head2 LEAVE
=head2 X<LEAVE|LEAVE (phasers)>
Runs at every block exit time (even stack unwinds from exceptions).
Expand All @@ -272,7 +272,7 @@ stack is unwinding, the unwinding continues and collects exceptions to be
handled. When the unwinding is completed all new exceptions are thrown from
that point.
=head2 KEEP
=head2 X<KEEP|KEEP (phasers)>
Runs at every successful block exit, as part of the LEAVE queue (shares the
same order of execution).
Expand All @@ -281,12 +281,12 @@ For phasers such as C<KEEP> and C<POST> that are run when exiting a scope
normally, the return value (if any) from that scope is available as the current
topic within the phaser.
=head2 UNDO
=head2 X<UNDO|UNDO (phasers)>
Runs at every unsuccessful block exit, as part of the LEAVE queue (shares the
same order of execution).
=head2 PRE
=head2 X<PRE|PRE (phasers)>
Asserts a precondition at every block entry. Runs before the ENTER phase.
Expand All @@ -296,7 +296,7 @@ The exceptions thrown by failing C<PRE> and C<POST> phasers cannot be caught by
a C<CATCH> in the same block, which implies that C<POST> phaser are not run if
a C<PRE> phaser fails.
=head2 POST
=head2 X<POST|POST (phasers)>
Asserts a postcondition at every block entry. Runs after the LEAVE phase.
Expand Down Expand Up @@ -324,13 +324,13 @@ a C<PRE> phaser fails.
C<FIRST>, C<NEXT>, and C<LAST> are meaningful only within the lexical scope of
a loop, and may occur only at the top level of such a loop block.
=head2 FIRST
=head2 X<FIRST|FIRST (phasers)>
Runs at loop initialization, before ENTER.
Can have a return value that is provided even in later phases.
=head2 NEXT
=head2 X<NEXT|NEXT (phasers)>
Runs when loop is continued (either through C<next> or because you got to the
bottom of the loop and are looping back around), before LEAVE.
Expand All @@ -341,31 +341,31 @@ phaser is not executed if the loop block is exited via any exception other than
the control exception thrown by C<next>. In particular, a C<last> bypasses
evaluation of C<NEXT> phasers.
=head2 LAST
=head2 X<LAST|LAST (phasers)>
Runs when loop is aborted (either through C<last>, or C<return>, or because you
got to the bottom of the loop and are done), after LEAVE.
=head1 Exception Handling Phasers
=head2 CATCH
=head2 X<CATCH|CATCH (phasers)>
Runs when an exception is raised by the current block, before the LEAVE phase.
=head2 CONTROL
=head2 X<CONTROL|CONTROL (phasers)>
Runs when a control exception is raised by the current block, before the LEAVE
phase.
=head1 Object Phasers
=head2 COMPOSE
=head2 X<COMPOSE|COMPOSE (phasers)>
Runs when a role is composed into a class.
=head1 Asynchronous Phasers
=head2 LAST
=head2 X<LAST|asynchronous LAST (phasers)>
Runs when a L<Supply|/type/Supply> finishes with a call to C<done> or when a
C<supply> block exits normally. It runs completely after the C<whenever> block
Expand All @@ -375,7 +375,7 @@ This phaser reuses the name C<LAST>, but works differently from the C<LAST> loop
phaser. This phaser is similar to setting the C<done> routine while tapping a
supply with C<tap>.
=head2 QUIT
=head2 X<QUIT|QUIT asynchronous QUIT (phasers)>
Runs when a L<Supply|/type/Supply> terminates early with an exception. It runs
after the C<whenever> block it is placed within finishes.
Expand Down
10 changes: 6 additions & 4 deletions doc/Type/Seq.pod
Expand Up @@ -26,10 +26,12 @@ This implies that you cannot iterate the same C<Seq> object twice (otherwise
it couldn't throw away old values), so this dies:
=begin code :allow<L>
my \lines := open('README').lines;
for lines { .say };
for lines { .say }; # dies with "This Seq has already been iterated [...]"
# of type L<X::Seq::Consumed>
my @a = 1,2,3;
my @b = <a b c>;
my \c = @a Z=> @b;
.say for c;
.say for c; # dies with "This Seq has already been iterated, and its values consumed [...]"
# of type L<X::Seq::Consumed>
=end code
A high-level construct to generate a C<Seq> is C<gather/take>, as well as many
Expand Down

0 comments on commit ffb9ce7

Please sign in to comment.