Skip to content

Commit 8c7a422

Browse files
committed
Specify yield* and await for in more detail.
1 parent b3e2898 commit 8c7a422

File tree

1 file changed

+66
-24
lines changed

1 file changed

+66
-24
lines changed

specification/dartLangSpec.tex

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
% - Add requirement that the iterator of a for-in statement must have
104104
% type `Iterator`.
105105
% - Clarify which constructors are covered by the section 'Constant
106-
% Constructors' and removed confusing redundancy in definiton of
106+
% Constructors' and removed confusing redundancy in definition of
107107
% potentially constant expressions.
108108
% - Integrate the feature specification of collection literal elements
109109
% (aka UI-as-code).
@@ -6719,7 +6719,7 @@ \subsection{Constants}
67196719
% be computed statically without running user code.
67206720

67216721
% A validly typed potentially constant expression can still fail when evaluated.
6722-
% If that happens in a const invociation, it's a compile-time error.
6722+
% If that happens in a const invocation, it's a compile-time error.
67236723

67246724
\LMHash{}%
67256725
It is a compile-time error if an expression is required to be
@@ -10352,7 +10352,7 @@ \subsection{Function Invocation}
1035210352
}
1035310353

1035410354
%\LMHash{}%
10355-
%When a stream is canceled, the implementation must wait for the cancelation future returned by \code{cancell()} to complete before proceeding.
10355+
%When a stream is canceled, the implementation must wait for the cancellation future returned by \code{cancell()} to complete before proceeding.
1035610356

1035710357

1035810358
\subsubsection{Actual Argument Lists}
@@ -16017,7 +16017,8 @@ \subsection{Yield-Each}
1601716017
if the class of $o$ is not a subtype of \code{Iterable<$T_f$>}.
1601816018
Otherwise
1601916019
\item
16020-
The method \code{iterator} is invoked upon $o$ returning an object $i$.
16020+
The getter \code{iterator} is invoked upon $o$ returning an object $i$.
16021+
Otherwise
1602116022
\item
1602216023
\label{moveNext} The \code{moveNext} method of $i$ is invoked on it
1602316024
with no arguments.
@@ -16051,35 +16052,76 @@ \subsection{Yield-Each}
1605116052
It is a dynamic type error if the class of $o$
1605216053
is not a subtype of \code{Stream<$T_f$>}.
1605316054
Otherwise
16055+
\item
16056+
If the stream associated with $m$ has been cancelled,
16057+
then execution of $s$ completes by returning without a value.
16058+
\commentary{In this case, the \code{\YIELD*} operation does
16059+
not begin to listen to the stream $o$.}
16060+
Otherwise
16061+
\item
16062+
The $o$ stream is listened to by invoking \code{$v_o$.listen}
16063+
with system provided arguments,
16064+
where $v_o$ is a fresh variable referencing the stream $o$.
16065+
Let $u$ be the stream subscription returned by the call to
16066+
\code{$p$.listen} and let $v$ be a fresh variable bound to $u$.
16067+
\item
16068+
If the stream associated with $m$ is paused, then $u$ is immediately
16069+
paused as if by invoking \code{$v$.pause} with no arguments.
16070+
\item{}
16071+
If the stream associated with $m$ has been cancelled, then
16072+
$u$ is cancelled by executing \code{await $v$.cancel();}.
16073+
If this execution does not throw, the execution of $s$
16074+
completes by returning without a value.
16075+
% This can only happen if a call to "listen" or "pause" above has
16076+
% side effects which cancels the stream of $m$.
1605416077
\item
1605516078
The nearest enclosing asynchronous for loop (\ref{asynchronousFor-in}),
1605616079
if any, is paused.
1605716080
\item
16058-
The $o$ stream is listened to, creating a subscription $s$,
16059-
and for each event $x$, or error $e$ with stack trace $t$, of $s$:
16081+
Execution of $m$ is suspended.
16082+
While $m$ is suspended, the following reactions happen if $u$ delivers
16083+
an event or if the stream associated with $m$ is paused, resumed or cancelled.
16084+
\commentary{It is unspecified what happens if $u$ delivers events
16085+
before $m$ is suspended or after $m$ is resumed, or if $u$ delivers events
16086+
after a call to \code{$v$.cancel} or a call to \code{$v$.pause} which has
16087+
not been followed by a call to \code{$v$.resume}, or after having delivered
16088+
a done event.}
16089+
% Such events should be ignored.
1606016090
\begin{itemize}
1606116091
\item
16062-
If the stream $u$ associated with $m$ has been paused,
16063-
then execution of $m$ is suspended until $u$ is resumed or canceled.
16092+
If the stream associated with $m$ becomes paused,
16093+
then $u$ is paused by executing \code{$v$.pause();}.
16094+
It is unspecified what happens if this execution throws.
16095+
% The error can be passed to \code{Zone.current.handleUncaughtError}.
1606416096
\item
16065-
If the stream $u$ associated with $m$ has been canceled,
16066-
then $s$ is canceled by evaluating \code{\AWAIT{} v.cancel()}
16067-
where $v$ is a fresh variable referencing the stream subscription $s$.
16068-
Then, if the cancel completed normally,
16069-
the stream execution of $s$ returns without an object
16070-
(\ref{statementCompletion}).
16097+
If the stream associated with $m$ is resumed after being paused,
16098+
then $u$ is resumed as by executing \code{$v$.resume();}.
16099+
It is unspecified what happens if this execution throws.
16100+
% The error can be passed to \code{Zone.current.handleUncaughtError}.
16101+
\item
16102+
If the stream associated with $m$ is cancelled,
16103+
then $u$ is also cancelled as by executing \code{await $v$.cancel();}.
16104+
16105+
At some future time, execution of $m$ resumes. If the execution above
16106+
completed by throwing an error \metavar{er} and stack trace \metavar{st},
16107+
then execution of $s$ completes by throwing \metavar{er}
16108+
and stack trace \metavar{st}.
16109+
Otherwise, execution of $s$ completes by returning without a value.
1607116110
\item
16072-
Otherwise, $x$, or $e$ with $t$, are added to
16073-
the stream associated with $m$ in the order they appear in $o$.
16074-
\commentary{%
16075-
Note that a dynamic error occurs if $x$ is added
16076-
and the dynamic type of $x$ is not a subtype of
16077-
the element type of said stream.%
16078-
}
16079-
The function $m$ may suspend.
16111+
If $u$ emits a data event with value $x$,
16112+
then if the runtime type of $x$ is not a subtype of $T_v$,
16113+
then the stream associated with $m$ emits a dynamic type error.
16114+
Otherwise the stream associated with $m$ immediately emits
16115+
a data event with value $x$.
16116+
\item
16117+
If $u$ emits an error event with error \metavar{er}
16118+
and stack trace \metavar{st},
16119+
then the stream associated with $m$ immediately emits an error event
16120+
with error \metavar{er} and stack trace \metavar{st}.
16121+
\item
16122+
If $u$ closes \commentary{(by emitting a done event)},
16123+
then execution of $m$ resumes and execution of $s$ completes normally.
1608016124
\end{itemize}
16081-
\item
16082-
If the stream $o$ is done, execution of $s$ completes normally.
1608316125
\end{itemize}
1608416126

1608516127

0 commit comments

Comments
 (0)