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

Side by Side Diff: docs/language/dartLangSpec.tex

Issue 993213002: Correct reference to definition of flatten (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 996
997 \LMHash{} 997 \LMHash{}
998 It is a compile-time error if the arity of the user-declared operator \code{ \~ {}} is not 0. 998 It is a compile-time error if the arity of the user-declared operator \code{ \~ {}} is not 0.
999 999
1000 \LMHash{} 1000 \LMHash{}
1001 It is a compile-time error to declare an optional parameter in an operator. 1001 It is a compile-time error to declare an optional parameter in an operator.
1002 1002
1003 \LMHash{} 1003 \LMHash{}
1004 It is a static warning if the return type of the user-declared operator \code{[] =} is explicitly declared and not \VOID{}. 1004 It is a static warning if the return type of the user-declared operator \code{[] =} is explicitly declared and not \VOID{}.
1005 1005
1006 % add rationale: return in []= methods will have no effect, a the expression alw ays returns its second argument (the RHS of the assignment, for consistency with assignment in general). So it's best to enforce this by declaring the method to be void, even though the expression that uses it returns an object with the typ e of the RHS, as described in \ref{assignment}.
1007
1006 1008
1007 \subsection{Getters} 1009 \subsection{Getters}
1008 \LMLabel{getters} 1010 \LMLabel{getters}
1009 1011
1010 \LMHash{} 1012 \LMHash{}
1011 Getters are functions (\ref{functions}) that are used to retrieve the values of object properties. 1013 Getters are functions (\ref{functions}) that are used to retrieve the values of object properties.
1012 1014
1013 \begin{grammar} 1015 \begin{grammar}
1014 {\bf getterSignature:} 1016 {\bf getterSignature:}
1015 returnType? \GET{} identifier 1017 returnType? \GET{} identifier
(...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after
3083 3085
3084 $(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$
3085 is 3087 is
3086 3088
3087 $(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$.
3088 3090
3089 \LMHash{} 3091 \LMHash{}
3090 The static type of a function literal of the form 3092 The static type of a function literal of the form
3091 3093
3092 $(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$
3093 is $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarro w Future<T_0>$, where $T_0$ is the static type of $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.
3096
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}.
3099 }
3100
3094 3101
3095 \LMHash{} 3102 \LMHash{}
3096 The static type of a function literal of the form 3103 The static type of a function literal of the form
3097 3104
3098 $(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$ 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$
3099 is 3106 is
3100 3107
3101 $(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$. 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$.
3102 3109
3103 \LMHash{} 3110 \LMHash{}
3104 The static type of a function literal of the form 3111 The static type of a function literal of the form
3105 3112
3106 $(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$ 3113 $(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$
3107 3114
3108 is $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightar row Future<T_0>$, where $T_0$ is the static type of $e$. 3115 is $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightar row Future<flatten(T_0)>$, where $T_0$ is the static type of $e$.
3109 3116
3110 \LMHash{} 3117 \LMHash{}
3111 The static type of a function literal of the form 3118 The static type of a function literal of the form
3112 3119
3113 $(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])\{s\}$ 3120 $(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])\{s\}$
3114 3121
3115 is $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarro w \DYNAMIC{}$. 3122 is $(T_1 \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}]) \rightarro w \DYNAMIC{}$.
3116 3123
3117 \LMHash{} 3124 \LMHash{}
3118 The static type of a function literal of the form 3125 The static type of a function literal of the form
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
3772 } 3779 }
3773 3780
3774 \LMHash{} 3781 \LMHash{}
3775 If $n < h$, or $n > m$, the method lookup has failed. Furthermore, each $x_i, n +1 \le i \le n+k$, must have a corresponding named parameter in the set $\{p_{m +1}, \ldots, p_{h+l}\}$ or the method lookup also fails. If $v_o$ is an instanc e of \code{Type} but $o$ is not a constant type literal, then if $m$ is a method that forwards (\ref{functionDeclarations}) to a static method, method lookup fa ils. Otherwise method lookup has succeeded. 3782 If $n < h$, or $n > m$, the method lookup has failed. Furthermore, each $x_i, n +1 \le i \le n+k$, must have a corresponding named parameter in the set $\{p_{m +1}, \ldots, p_{h+l}\}$ or the method lookup also fails. If $v_o$ is an instanc e of \code{Type} but $o$ is not a constant type literal, then if $m$ is a method that forwards (\ref{functionDeclarations}) to a static method, method lookup fa ils. Otherwise method lookup has succeeded.
3776 3783
3777 \LMHash{} 3784 \LMHash{}
3778 If the method lookup succeeded, the body of $f$ is executed with respect to the bindings that resulted from the evaluation of the argument list, and with \THIS{ } bound to $v_o$. The value of $i$ is the value returned after $f$ is executed. 3785 If the method lookup succeeded, the body of $f$ is executed with respect to the bindings that resulted from the evaluation of the argument list, and with \THIS{ } bound to $v_o$. The value of $i$ is the value returned after $f$ is executed.
3779 3786
3780 \LMHash{} 3787 \LMHash{}
3781 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $v_o$ with respect to $L$. 3788 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $v_o$ with respect to $L$.
3782 f $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, th en if $g$ is a getter that forwards to a static getter, getter lookup fails. 3789 If $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, t hen if $g$ is a getter that forwards to a static getter, getter lookup fails.
3783 If the getter lookup succeeded, let $v_g$ be the value of the getter invocation $o.m$. Then the value of $i$ is the result of invoking 3790 If the getter lookup succeeded, let $v_g$ be the value of the getter invocation $o.m$. Then the value of $i$ is the result of invoking
3784 the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_ n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$. 3791 the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_ n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$.
3785 3792
3786 \LMHash{} 3793 \LMHash{}
3787 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : 3794 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that :
3788 \begin{itemize} 3795 \begin{itemize}
3789 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3796 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3790 \item \code{im.memberName} evaluates to \code{'m'}. 3797 \item \code{im.memberName} evaluates to \code{'m'}.
3791 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. 3798 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}.
3792 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}. 3799 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}.
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
4589 4596
4590 \rationale{ 4597 \rationale{
4591 An await expression has no meaning in a synchronous function. If such a function were to suspend waiting for a future, it would no longer be synchronous. 4598 An await expression has no meaning in a synchronous function. If such a function were to suspend waiting for a future, it would no longer be synchronous.
4592 } 4599 }
4593 4600
4594 \commentary{ 4601 \commentary{
4595 It is not a static warning if the type of $e$ is not a subtype of \code{Future}. Tools may choose to give a hint in such cases. 4602 It is not a static warning if the type of $e$ is not a subtype of \code{Future}. Tools may choose to give a hint in such cases.
4596 } 4603 }
4597 4604
4598 \LMHash{} 4605 \LMHash{}
4599 Let $flatten(T) = flatten(S)$ if $T = Future<S>$, and $T$ otherwise. The static type of $a$ is $flatten(T)$ where $T$ is the static type of $e$. 4606 The static type of $a$ is $flatten(T)$ (the $flatten$ function is defined in sec tion \ref{functionExpressions}) where $T$ is the static type of $e$.
4600
4601 \rationale{
4602 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}.
4603 }
4604
4605 4607
4606 4608
4607 4609
4608 \subsection{ Postfix Expressions} 4610 \subsection{ Postfix Expressions}
4609 \LMLabel{postfixExpressions} 4611 \LMLabel{postfixExpressions}
4610 4612
4611 \LMHash{} 4613 \LMHash{}
4612 Postfix expressions invoke the postfix operators on objects. 4614 Postfix expressions invoke the postfix operators on objects.
4613 4615
4614 \begin{grammar} 4616 \begin{grammar}
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
5732 5734
5733 \commentary{ 5735 \commentary{
5734 In the simplest case, the immediately enclosing function is an ordinary, synchro nous non-generator, and upon function termination, the current return value is g iven to the caller. The other possibility is that the function is marked \ASYNC {}, in which case the current return value is used to complete the future associ ated with the function invocation. Both these scenarios are specified in section \ref{functionInvocation}. 5736 In the simplest case, the immediately enclosing function is an ordinary, synchro nous non-generator, and upon function termination, the current return value is g iven to the caller. The other possibility is that the function is marked \ASYNC {}, in which case the current return value is used to complete the future associ ated with the function invocation. Both these scenarios are specified in section \ref{functionInvocation}.
5735 The enclosing function cannot be marked as generator (i.e, \ASYNC* or \SYNC*), s ince generators are not allowed to contain a statement of the form \code{\RETURN {} $e$;} as discussed below. 5737 The enclosing function cannot be marked as generator (i.e, \ASYNC* or \SYNC*), s ince generators are not allowed to contain a statement of the form \code{\RETURN {} $e$;} as discussed below.
5736 } 5738 }
5737 5739
5738 \LMHash{} 5740 \LMHash{}
5739 Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing funct ion. 5741 Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing funct ion.
5740 5742
5741 \LMHash{} 5743 \LMHash{}
5742 It is a static type warning if the body of $f$ is marked \ASYNC{} and the type \ code{Future$<$flatten(T)$>$} (\ref{awaitExpressions}) may not be assigned to the declared return type of $f$. Otherwise, it is a static type warning if $T$ ma y not be assigned to the declared return type of $f$. 5744 It is a static type warning if the body of $f$ is marked \ASYNC{} and the type \ code{Future$<$flatten(T)$>$} (\ref{functionExpressions}) may not be assigned to the declared return type of $f$. Otherwise, it is a static type warning if $T $ may not be assigned to the declared return type of $f$.
5743 5745
5744 \LMHash{} 5746 \LMHash{}
5745 Let $S$ be the runtime type of $o$. In checked mode: 5747 Let $S$ be the runtime type of $o$. In checked mode:
5746 \begin{itemize} 5748 \begin{itemize}
5747 \item If the body of $f$ is marked \ASYNC{} (\ref{functions}) it is a dynamic t ype error if $o$ is not \NULL{} (\ref{null}) and \code{Future$<$S$>$} is not a s ubtype of the actual return type (\ref{actualTypeOfADeclaration}) of $f$. 5749 \item If the body of $f$ is marked \ASYNC{} (\ref{functions}) it is a dynamic t ype error if $o$ is not \NULL{} (\ref{null}) and \code{Future$<$S$>$} is not a s ubtype of the actual return type (\ref{actualTypeOfADeclaration}) of $f$.
5748 \item Otherwise, it is a dynamic type error if $o$ is not \NULL{} and the runtim e type of $o$ is not a subtype of the actual return type of $f$. 5750 \item Otherwise, it is a dynamic type error if $o$ is not \NULL{} and the runtim e type of $o$ is not a subtype of the actual return type of $f$.
5749 \end{itemize} 5751 \end{itemize}
5750 5752
5751 \LMHash{} 5753 \LMHash{}
5752 It is a compile-time error if a return statement of the form \code{\RETURN{} $e$ ;} appears in a generative constructor (\ref{generativeConstructors}). 5754 It is a compile-time error if a return statement of the form \code{\RETURN{} $e$ ;} appears in a generative constructor (\ref{generativeConstructors}).
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
7381 7383
7382 The invariant that each normative paragraph is associated with a line 7384 The invariant that each normative paragraph is associated with a line
7383 containing the text \LMHash{} should be maintained. Extra occurrences 7385 containing the text \LMHash{} should be maintained. Extra occurrences
7384 of \LMHash{} can be added if needed, e.g., in order to make 7386 of \LMHash{} can be added if needed, e.g., in order to make
7385 individual \item{}s in itemized lists addressable. Each \LM.. command 7387 individual \item{}s in itemized lists addressable. Each \LM.. command
7386 must occur on a separate line. \LMHash{} must occur immediately 7388 must occur on a separate line. \LMHash{} must occur immediately
7387 before the associated paragraph, and \LMLabel must occur immediately 7389 before the associated paragraph, and \LMLabel must occur immediately
7388 after the associated \section{}, \subsection{} etc. 7390 after the associated \section{}, \subsection{} etc.
7389 7391
7390 ---------------------------------------------------------------------- 7392 ----------------------------------------------------------------------
OLDNEW
« 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