OLD | NEW |
---|---|
1 \documentclass{article} | 1 \documentclass{article} |
2 \usepackage{epsfig} | 2 \usepackage{epsfig} |
3 \usepackage{color} | 3 \usepackage{color} |
4 \usepackage{dart} | 4 \usepackage{dart} |
5 \usepackage{bnf} | 5 \usepackage{bnf} |
6 \usepackage{hyperref} | 6 \usepackage{hyperref} |
7 \usepackage{lmodern} | 7 \usepackage{lmodern} |
8 \newcommand{\code}[1]{{\sf #1}} | 8 \newcommand{\code}[1]{{\sf #1}} |
9 \title{Dart Programming Language Specification \\ | 9 \title{Dart Programming Language Specification \\ |
10 {\large Version 1.9}} | 10 {\large Version 1.9}} |
(...skipping 3074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3085 | 3085 |
3086 $(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{ n+k} = d_k]) => e$ | 3086 $(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{ n+k} = d_k]) => e$ |
3087 is | 3087 is |
3088 | 3088 |
3089 $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarrow T _0$, where $T_0$ is the static type of $e$. | 3089 $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarrow T _0$, where $T_0$ is the static type of $e$. |
3090 | 3090 |
3091 \LMHash{} | 3091 \LMHash{} |
3092 The static type of a function literal of the form | 3092 The static type of a function literal of the form |
3093 | 3093 |
3094 $(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{ n+k} = d_k])$ \ASYNC{} $=> e$ | 3094 $(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{ n+k} = d_k])$ \ASYNC{} $=> e$ |
3095 is $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarro w Future<flatten(T_0)>$, where $T_0$ is the static type of $e$ and $flatten(T) = flatten(S)$ if $T = Future<S>$, and $T$ otherwise. | 3095 is $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarro w Future<flatten(T_0)>$, where $T_0$ is the static type of $e$ and $flatten(T) = flatten(S)$ if $T = Future<S>$ and $T \ne S$, and $T$ otherwise. |
Paul Berry
2015/03/13 19:59:11
I'm confused as to why $T \ne S$ is necessary. Do
Lasse Reichstein Nielsen
2015/03/15 11:53:15
I think we should flatten if T is a subtype of Fut
gbracha
2015/03/16 20:25:23
The intent was to use subtyping, not equality, but
| |
3096 | 3096 |
3097 \rationale{ | 3097 \rationale{ |
3098 We collapse multiple layers of futures into one. If $e$ evaluates to a future $f $, the future will not invoke its \code{then()} callback until f completes to a non-future value, and so the result of an await is never a future, and the resul t of an async function will never have type \code{Future$<X>$} where $X$ itself is an invocation of \code{Future}. | 3098 We collapse multiple layers of futures into one. If $e$ evaluates to a future $f $, the future will not invoke its \code{then()} callback until f completes to a non-future value, and so the result of an await is never a future, and the resul t of an async function will never have type \code{Future$<X>$} where $X$ itself is an invocation of \code{Future}. |
3099 | |
3100 The sole exception to that would be a type $X$ that extended or implemented \cod e{Future$<X>$}. In that case, the result type is $X$ and no further unwrapping t akes place. | |
Paul Berry
2015/03/13 19:59:11
This is in a \rationale block, so I would expect t
Lasse Reichstein Nielsen
2015/03/15 11:53:15
So, as stated above, I disagree with that choice.
Paul Berry
2015/03/15 13:57:22
Understood. What I wish we could say is:
flatt
| |
3099 } | 3101 } |
3100 | 3102 |
3101 | 3103 |
3102 \LMHash{} | 3104 \LMHash{} |
3103 The static type of a function literal of the form | 3105 The static type of a function literal of the form |
3104 | 3106 |
3105 $(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_ {n+k} : d_k\}) => e$ | 3107 $(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_ {n+k} : d_k\}) => e$ |
3106 is | 3108 is |
3107 | 3109 |
3108 $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightarrow T_0$, where $T_0$ is the static type of $e$. | 3110 $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightarrow T_0$, where $T_0$ is the static type of $e$. |
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5906 Next, $o$ is added to the iterable or stream associated with the immediately enc losing function. | 5908 Next, $o$ is added to the iterable or stream associated with the immediately enc losing function. |
5907 | 5909 |
5908 \LMHash{} | 5910 \LMHash{} |
5909 If the enclosing function $m$ is marked \ASYNC* and the stream $u$ associated wi th $m$ has been canceled, then let $c$ be the \FINALLY{} clause (\ref{try}) of t he innermost enclosing try-finally statement, if any. If $c$ is defined, let $h$ be the handler induced by $c$. If $h$ is defined, control is transferred to $h$ . If $h$ is undefined, the immediately enclosing function terminates. | 5911 If the enclosing function $m$ is marked \ASYNC* and the stream $u$ associated wi th $m$ has been canceled, then let $c$ be the \FINALLY{} clause (\ref{try}) of t he innermost enclosing try-finally statement, if any. If $c$ is defined, let $h$ be the handler induced by $c$. If $h$ is defined, control is transferred to $h$ . If $h$ is undefined, the immediately enclosing function terminates. |
5910 | 5912 |
5911 \rationale{ | 5913 \rationale{ |
5912 The stream associated with an asynchronous generator could be canceled by any co de with a reference to that stream at any point where the generator was passivat ed. Such a cancellation constitutes an irretrievable error for the generator. A t this point, the only plausible action for the generator is to clean up after i tself via its \FINALLY{} clauses. | 5914 The stream associated with an asynchronous generator could be canceled by any co de with a reference to that stream at any point where the generator was passivat ed. Such a cancellation constitutes an irretrievable error for the generator. A t this point, the only plausible action for the generator is to clean up after i tself via its \FINALLY{} clauses. |
5913 } | 5915 } |
5914 | 5916 |
5915 \LMHash{} | 5917 \LMHash{} |
5918 Otherwise, if the enclosing function $m$ is marked \ASYNC* (\ref{functions}) the n the enclosing function may suspend. | |
Lasse Reichstein Nielsen
2015/03/15 11:53:15
I still think it should be "must suspend". If that
gbracha
2015/03/16 20:25:22
Per discussion with Lars, we are not doing that. T
| |
5919 | |
5920 \rationale { | |
5921 If a \YIELD{} occurred inside an infinite loop and the enclosing function never suspended, there might not be an opportunity for consumers of the enclosing str eam to run and access the data in the stream. The stream might then accumulate an unbounded number of elements. Such a situation is untenable. Therefore, we al low the enclosing function to be suspended when a new value is added to its asso ciated stream. However, it is not essential (and in fact, can be quite costly) t o suspend the function on every \YIELD{}. The implementation is free to decide h ow often to suspend the enclosing function. The only requirement is that consume rs are not blocked indefinitely. | |
5922 } | |
5923 | |
5924 | |
5925 \LMHash{} | |
5916 If the enclosing function $m$ is marked \SYNC* (\ref{functions}) then: | 5926 If the enclosing function $m$ is marked \SYNC* (\ref{functions}) then: |
5917 \begin{itemize} | 5927 \begin{itemize} |
5918 \item | 5928 \item |
5919 Execution of the function $m$ immediately enclosing $s$ is suspended until the m ethod \code{moveNext()} is invoked upon the iterator used to initiate the curren t invocation of $m$. | 5929 Execution of the function $m$ immediately enclosing $s$ is suspended until the m ethod \code{moveNext()} is invoked upon the iterator used to initiate the curren t invocation of $m$. |
5920 \item | 5930 \item |
5921 The current call to \code{moveNext()} returns \TRUE. | 5931 The current call to \code{moveNext()} returns \TRUE. |
5922 \end{itemize} | 5932 \end{itemize} |
5923 | 5933 |
5924 \LMHash{} | 5934 \LMHash{} |
5925 It is a compile-time error if a yield statement appears in a function that is no t a generator function. | 5935 It is a compile-time error if a yield statement appears in a function that is no t a generator function. |
(...skipping 14 matching lines...) Expand all Loading... | |
5940 \LMHash{} | 5950 \LMHash{} |
5941 The {\em yield-each statement} adds a series of values to the result of a gener ator function (\ref{functions}). | 5951 The {\em yield-each statement} adds a series of values to the result of a gener ator function (\ref{functions}). |
5942 | 5952 |
5943 \begin{grammar} | 5953 \begin{grammar} |
5944 {\bf yieldEachStatement:} | 5954 {\bf yieldEachStatement:} |
5945 \YIELD* expression `{\escapegrammar ;}' | 5955 \YIELD* expression `{\escapegrammar ;}' |
5946 . | 5956 . |
5947 \end{grammar} | 5957 \end{grammar} |
5948 | 5958 |
5949 \LMHash{} | 5959 \LMHash{} |
5950 Execution of a statement s of the form \code{\YIELD* $e$;} proceeds as follows: | 5960 Execution of a statement $s$ of the form \code{\YIELD* $e$;} proceeds as follow s: |
5951 | 5961 |
5952 \LMHash{} | 5962 \LMHash{} |
5953 First, the expression $e$ is evaluated to an object $o$. If the immediately encl osing function $m$ is synchronous, then it is a dynamic error if the class of $o $ does not implement \code{Iterable}. If $m$ asynchronous, then it is a dynamic error if the class of $o$ does not implement \code{Stream}. Next, for each elem ent $x$ of $o$: | 5963 First, the expression $e$ is evaluated to an object $o$. |
5964 | |
5965 \LMHash{} | |
5966 If the immediately enclosing function $m$ is marked \SYNC* (\ref{functions}), th en: | |
5967 \begin{enumerate} | |
5968 \item It is a dynamic error if the class of $o$ does not implement \code{Iterabl e}. Otherwise | |
Lasse Reichstein Nielsen
2015/03/15 11:53:15
Still think this line should be dropped. If you ca
gbracha
2015/03/16 20:25:22
My goal in this CL is to deal with oversights and
| |
5969 \item The method \cd{iterator} is invoked upon $o$ returning an object $i$. | |
Lasse Reichstein Nielsen
2015/03/15 11:53:16
Or it may throw - implementing an interface doesn'
| |
5970 \item \label{moveNext} The \cd{moveNext} method of $i$ is invoked. If \cd{moveNe xt} returns \FALSE{} execution of $s$ is complete. Otherwise | |
Lasse Reichstein Nielsen
2015/03/15 11:53:16
Should we say the the moveNext method of i is invo
Lasse Reichstein Nielsen
2015/03/15 11:53:16
The result of moveNext should be subjected to bool
gbracha
2015/03/16 22:21:40
Done.
| |
5971 \item An element $x$ is extracted from $i$ and $x$ is added to the iterable or s tream associated with $m$. | |
Lasse Reichstein Nielsen
2015/03/15 11:53:16
"extracted from" doesn't say how.
What you do is
gbracha
2015/03/16 22:21:40
But for streams it's a bit different. So I abstrac
Lasse Reichstein Nielsen
2015/03/17 07:11:21
It's very different for Stream, but this text only
| |
5972 Execution of the function $m$ immediately enclosing $s$ is suspended until the m ethod \code{moveNext()} is invoked upon the iterator used to initiate the curren t invocation of $m$, at which point execution of $s$ continues at \ref{moveNext} . | |
5973 \item | |
5974 The current call to \code{moveNext()} returns \TRUE. | |
5975 \end{enumerate} | |
5976 | |
5977 \LMHash{} | |
5978 If $m$ is marked \ASYNC* (\ref{functions}), then: | |
5979 \begin{itemize} | |
5980 \item It is a dynamic error if the class of $o$ does not implement \code{Stream }. Otherwise | |
5981 \item For each element $x$ of $o$: | |
5954 \begin{itemize} | 5982 \begin{itemize} |
5955 \item | 5983 \item |
5956 If $m$ is marked \ASYNC* (\ref{functions}) and the stream $u$ associated with $m $ has been paused, then execution of $m$ is suspended until $u$ is resumed or c anceled. | 5984 If the stream $u$ associated with $m$ has been paused, then execution of $m$ is suspended until $u$ is resumed or canceled. |
5985 \item | |
5986 If the stream $u$ associated with $m$ has been canceled, then let $c$ be the \FI NALLY{} clause (\ref{try}) of the innermost enclosing try-finally statement, if any. If $c$ is defined, let $h$ be the handler induced by $c$. If $h$ is define d, control is transferred to $h$. If $h$ is undefined, the immediately enclosing function terminates. | |
5957 \item | 5987 \item |
5958 $x$ is added to the iterable or stream associated with $m$ in the order it appe ars in $o$. | 5988 Otherwise, $x$ is added to the stream associated with $m$ in the order it appea rs in $o$. The function $m$ may suspend. |
5959 \item | 5989 \end{itemize} |
5960 If $m$ is marked \ASYNC* and the stream $u$ associated with $m$ has been cancele d, then let $c$ be the \FINALLY{} clause (\ref{try}) of the innermost enclosing try-finally statement, if any. If $c$ is defined, let $h$ be the handler induce d by $c$. If $h$ is defined, control is transferred to $h$. If $h$ is undefined, the immediately enclosing function terminates. | 5990 \item If the stream $o$ is done, execution of $s$ is complete. |
5961 \end{itemize} | 5991 \end{itemize} |
5962 | 5992 |
5963 \LMHash{} | |
5964 If the enclosing function is marked \SYNC* (\ref{functions}) then: | |
5965 \begin{itemize} | |
5966 \item | |
5967 Execution of the function $m$ immediately enclosing $s$ is suspended until the m ethod \code{moveNext()} is invoked upon the iterator used to initiate the curren t invocation of $m$. | |
5968 \item | |
5969 The current call to \code{moveNext()} returns \TRUE. | |
5970 \end{itemize} | |
5971 | 5993 |
5972 \LMHash{} | 5994 \LMHash{} |
5973 It is a compile-time error if a yield-each statement appears in a function that is not a generator function. | 5995 It is a compile-time error if a yield-each statement appears in a function that is not a generator function. |
5974 | 5996 |
5975 \LMHash{} | 5997 \LMHash{} |
5976 Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing funct ion. It is a static type warning if $T$ may not be assigned to the declared ret urn type of $f$. If $f$ is synchronous it is a static type warning if $T$ may not be assigned to \code{Iterable}. If $f$ is asynchronous it is a static type warning if $T$ may not be assigned to \code{Stream}. | 5998 Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing funct ion. It is a static type warning if $T$ may not be assigned to the declared ret urn type of $f$. If $f$ is synchronous it is a static type warning if $T$ may not be assigned to \code{Iterable}. If $f$ is asynchronous it is a static type warning if $T$ may not be assigned to \code{Stream}. |
5977 | 5999 |
5978 | 6000 |
5979 \subsection{ Assert} | 6001 \subsection{ Assert} |
5980 \LMLabel{assert} | 6002 \LMLabel{assert} |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7383 | 7405 |
7384 The invariant that each normative paragraph is associated with a line | 7406 The invariant that each normative paragraph is associated with a line |
7385 containing the text \LMHash{} should be maintained. Extra occurrences | 7407 containing the text \LMHash{} should be maintained. Extra occurrences |
7386 of \LMHash{} can be added if needed, e.g., in order to make | 7408 of \LMHash{} can be added if needed, e.g., in order to make |
7387 individual \item{}s in itemized lists addressable. Each \LM.. command | 7409 individual \item{}s in itemized lists addressable. Each \LM.. command |
7388 must occur on a separate line. \LMHash{} must occur immediately | 7410 must occur on a separate line. \LMHash{} must occur immediately |
7389 before the associated paragraph, and \LMLabel must occur immediately | 7411 before the associated paragraph, and \LMLabel must occur immediately |
7390 after the associated \section{}, \subsection{} etc. | 7412 after the associated \section{}, \subsection{} etc. |
7391 | 7413 |
7392 ---------------------------------------------------------------------- | 7414 ---------------------------------------------------------------------- |
OLD | NEW |