Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1495)

Unified Diff: docs/language/dartLangSpec.tex

Issue 3000063002: Specify that async functions start executing synchronously. (Closed)
Patch Set: Be explicit about delaying completion. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: docs/language/dartLangSpec.tex
diff --git a/docs/language/dartLangSpec.tex b/docs/language/dartLangSpec.tex
index 590001560230e3797700307a1fd1bc7b570edbfd..329de373ca67b08b58277fbe220bf65cd88bddcf 100644
--- a/docs/language/dartLangSpec.tex
+++ b/docs/language/dartLangSpec.tex
@@ -21,6 +21,7 @@
%
% 2.0
% - Don't allow functions as assert test values.
+% - Start running "async" functions synchronously.
%
% 1.15
% - Change how language specification describes control flow.
@@ -3788,7 +3789,19 @@ Two executions of an iterator interact only via state outside the function.
% The alternative would be to cache the results of an iterator in the iterable, and check the cache at each \YIELD{}. This would have strange issues as well. The yielded value might differ from the expression in the yield. And it is a potential memory leak as the cache is kept alive by any iterator.
\LMHash{}
-If $f$ is marked \ASYNC{} (\ref{functions}), then a fresh instance (\ref{generativeConstructors}) $o$ implementing the built-in class \code{Future} is associated with the invocation and immediately returned to the caller. The body of $f$ is scheduled for execution at some future time. The future $o$ will be completed when execution of the body of $f$ completes (\ref{completion}). If execution of the body returns a value, $o$ is completed with that value, if it completes normally or returns without a value, $o$ is completed with the \NULL{} value, and if it throws an exception $e$ and stack trace $t$, $o$ is completed with the error $e$ and stack trace $t$.
+If $f$ is marked \ASYNC{} (\ref{functions}), then a fresh instance (\ref{generativeConstructors}) $o$ implementing the built-in class \code{Future} is associated with the invocation.
+Then the body of $f$ is executed until it either suspends or completes, at which point $o$ is returned.
+\commentary{The body of $f$ may suspend during the evaluation of an \AWAIT{} expression or execution of an asynchronous \FOR{} loop.}
+The future $o$ is completed when execution of the body of $f$ completes (\ref{completion}).
+If execution of the body returns a value, $o$ is completed with that value,
+if it completes normally or returns without a value,
+$o$ is completed with the \NULL{} value,
+and if it throws an exception $e$ and stack trace $t$,
+$o$ is completed with the error $e$ and stack trace $t$.
+If execution of the body throws before the body suspends the first time,
+completion of $o$ happens at some future time after the invocation has returned.
+\rationale{The caller needs time to set up error handling for the returned future,
+so the future is not completed with an error {\em before} it has been returned.}
\LMHash{}
If $f$ is marked \ASYNC* (\ref{functions}), then a fresh instance $s$ implementing the built-in class \code{Stream} is associated with the invocation and immediately returned. When $s$ is listened to, execution of the body of $f$ will begin.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698