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

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

Issue 2998173002: Specify what "is equivalent to" means. (Closed)
Patch Set: Address comments. 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 unified diff | Download patch
« 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 \usepackage[T1]{fontenc} 8 \usepackage[T1]{fontenc}
9 \newcommand{\code}[1]{{\sf #1}} 9 \newcommand{\code}[1]{{\sf #1}}
10 \title{Dart Programming Language Specification \\ 10 \title{Dart Programming Language Specification \\
11 {5th edition draft}\\ 11 {5th edition draft}\\
12 {\large Version 2.0.0-dev}} 12 {\large Version 2.0.0-dev}}
13 13
14 % For information about Location Markers (and in particular the 14 % For information about Location Markers (and in particular the
15 % commands \LMHash and \LMLabel), see the long comment at the 15 % commands \LMHash and \LMLabel), see the long comment at the
16 % end of this file. 16 % end of this file.
17 17
18 % CHANGES 18 % CHANGES
19 % ======= 19 % =======
20 % Significant changes to the specification. 20 % Significant changes to the specification.
21 % 21 %
22 % 2.0 22 % 2.0
23 % - Don't allow functions as assert test values. 23 % - Don't allow functions as assert test values.
24 % - Start running "async" functions synchronously. 24 % - Start running "async" functions synchronously.
25 % - Specify what "is equivalent to" means.
25 % 26 %
26 % 1.15 27 % 1.15
27 % - Change how language specification describes control flow. 28 % - Change how language specification describes control flow.
28 % - Object initialization now specifies initialization order correctly. 29 % - Object initialization now specifies initialization order correctly.
29 % - Specifies that leaving an await-for loop must wait for the subscription 30 % - Specifies that leaving an await-for loop must wait for the subscription
30 % to be canceled. 31 % to be canceled.
31 % - An await-for loop only pauses the subscription if it does something async. 32 % - An await-for loop only pauses the subscription if it does something async.
32 % - Assert statements allows a "message" operand and a trailing comma. 33 % - Assert statements allows a "message" operand and a trailing comma.
33 % - The Null type is now considered a subtype of all types in most cases. 34 % - The Null type is now considered a subtype of all types in most cases.
34 % - Specify what NEWLINE means in multiline strings. 35 % - Specify what NEWLINE means in multiline strings.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 The notation $[x_1, \ldots, x_n/y_1, \ldots, y_n]E$ denotes a copy of $E$ in whi ch all occurrences of $y_i, 1 \le i \le n$ have been replaced with $x_i$. 178 The notation $[x_1, \ldots, x_n/y_1, \ldots, y_n]E$ denotes a copy of $E$ in whi ch all occurrences of $y_i, 1 \le i \le n$ have been replaced with $x_i$.
178 179
179 \LMHash{} 180 \LMHash{}
180 We sometimes abuse list or map literal syntax, writing $[o_1, \ldots, o_n]$ (re spectively $\{k_1: o_1, \ldots, k_n: o_n\}$) where the $o_i$ and $k_i$ may be ob jects rather than expressions. The intent is to denote a list (respectively map) object whose elements are the $o_i$ (respectively, whose keys are the $k_i$ and values are the $o_i$). 181 We sometimes abuse list or map literal syntax, writing $[o_1, \ldots, o_n]$ (re spectively $\{k_1: o_1, \ldots, k_n: o_n\}$) where the $o_i$ and $k_i$ may be ob jects rather than expressions. The intent is to denote a list (respectively map) object whose elements are the $o_i$ (respectively, whose keys are the $k_i$ and values are the $o_i$).
181 182
182 \LMHash{} 183 \LMHash{}
183 The specifications of operators often involve statements such as $x$ $op$ $y$ is equivalent to the method invocation $x.op(y)$. Such specifications should be un derstood as a shorthand for: 184 The specifications of operators often involve statements such as $x$ $op$ $y$ is equivalent to the method invocation $x.op(y)$. Such specifications should be un derstood as a shorthand for:
184 \begin{itemize} 185 \begin{itemize}
185 \item 186 \item
186 $x$ $op$ $y$ is equivalent to the method invocation $x.op^\prime(y)$, assuming the class of $x$ actually declared a non-operator method named $op^\prime$ defin ing the same function as the operator $op$. 187 $x$ $op$ $y$ is equivalent to the method invocation $x.op^\prime(y)$, assuming the class of $x$ actually declared a non-operator method named $op^\prime$ defin ing the same function as the operator $op$.
187 \end{itemize} 188 \end{itemize}
188 189
189 \rationale{This circumlocution is required because x.op(y), where op is an oper ator, is not legal syntax. However, it is painfully verbose, and we prefer to st ate this rule once here, and use a concise and clear notation across the specifi cation. 190 \rationale{This circumlocution is required because x.op(y), where op is an oper ator, is not legal syntax. However, it is painfully verbose, and we prefer to st ate this rule once here, and use a concise and clear notation across the specifi cation.
190 } 191 }
191 192
192 \LMHash{} 193 \LMHash{}
193 When the specification refers to the order given in the program, it means the or der of the program source code text, scanning left-to-right and top-to-bottom. 194 When the specification refers to the order given in the program, it means the or der of the program source code text, scanning left-to-right and top-to-bottom.
194 195
195 \LMHash{} 196 \LMHash{}
196 When the specification refers to a {\em fresh variable}, it means a variable wit h a name that doesn't occur anywhere in the current program. 197 When the specification refers to a {\em fresh variable}, it means a variable wit h a name that doesn't occur anywhere in the current program.
197 When the specification introduces a fresh variable bound to a value, the fresh v ariable is implicitly bound in a surrounding scope. 198 When the specification introduces a fresh variable bound to a value, the fresh v ariable is implicitly bound in a surrounding scope.
198 199
199 \LMHash{} 200 \LMHash{}
200 References to otherwise unspecified names of program entities (such as classes o r functions) are interpreted as the names of members of the Dart core library. 201 References to otherwise unspecified names of program entities (such as classes o r functions) are interpreted as the names of members of the Dart core library.
201 202
202 \commentary{ 203 \commentary{
203 Examples would be the classes \code{Object} and \code{Type} representing the roo t of the class hierarchy and the reification of runtime types respectively. 204 Examples would be the classes \code{Object} and \code{Type} representing the roo t of the class hierarchy and the reification of runtime types respectively.
204 } 205 }
205 206
207 \LMHash{}
208 When the specification says that one piece of syntax {\em is equivalent to} anot her piece of syntax, it means that it is equivalent in all ways, and the former syntax should generate the same static warnings and have the same runtime behavi or as the latter.
209 \commentary {
210 Error messages, if any, should always refer to the original syntax.
211 }
212 If execution or evaluation of a construct is said to be equivalent to execution or evaluation of another construct, then only the runtime behavior is equivalent , and only the static warnings or errors mentioned for the original syntax appli es.
213
206 \section{Overview} 214 \section{Overview}
207 \LMLabel{overview} 215 \LMLabel{overview}
208 216
209 \LMHash{} 217 \LMHash{}
210 Dart is a class-based, single-inheritance, pure object-oriented programming lang uage. Dart is optionally typed (\ref{types}) and supports reified generics. The run-time type of every object is represented as an instance of class \code{Type} which can be obtained by calling the getter \code{runtimeType} declared in cl ass \code{Object}, the root of the Dart class hierarchy. 218 Dart is a class-based, single-inheritance, pure object-oriented programming lang uage. Dart is optionally typed (\ref{types}) and supports reified generics. The run-time type of every object is represented as an instance of class \code{Type} which can be obtained by calling the getter \code{runtimeType} declared in cl ass \code{Object}, the root of the Dart class hierarchy.
211 219
212 \LMHash{} 220 \LMHash{}
213 Dart programs may be statically checked. The static checker will report some vio lations of the type rules, but such violations do not abort compilation or precl ude execution. 221 Dart programs may be statically checked. The static checker will report some vio lations of the type rules, but such violations do not abort compilation or precl ude execution.
214 222
215 \LMHash{} 223 \LMHash{}
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 542 }
535 543
536 \end{dartCode} 544 \end{dartCode}
537 545
538 % the grammar does not support local getters and setters. The local var discussi on does not seem to mention getters and setters based semantics. It simply discu sses the creation of the variable, not its access. Access is either assignment o r identifiers. Identifiers ignore the getter story. 546 % the grammar does not support local getters and setters. The local var discussi on does not seem to mention getters and setters based semantics. It simply discu sses the creation of the variable, not its access. Access is either assignment o r identifiers. Identifiers ignore the getter story.
539 547
540 \LMHash{} 548 \LMHash{}
541 The following rules apply to all static and instance variables. 549 The following rules apply to all static and instance variables.
542 550
543 \LMHash{} 551 \LMHash{}
544 A variable declaration of one of the forms \code{$T$ $v$;}, \code{$T$ $v$ = $ e$;} , \code{\CONST{} $T$ $v$ = $e$;}, \code{\FINAL{} $T$ $v$;} or \code{\FINA L{} $T$ $v$ = $e$;} always induces an implicit getter function (\ref{getters}) with signature 552 A variable declaration of one of the forms \code{$T$ $v$;}, \code{$T$ $v$ = $e $;} \code{\CONST{} $T$ $v$ = $e$;}, \code{\FINAL{} $T$ $v$;} or \code{\FINAL{} $T$ $v$ = $e$;} always induces an implicit getter function (\ref{getters}) with signature
545 553
546 $T$ \GET{} $v$ 554 $T$ \GET{} $v$
547 555
548 whose invocation evaluates as described below (\ref{evaluationOfImplicitVariable Getters}). 556 whose invocation evaluates as described below (\ref{evaluationOfImplicitVariable Getters}).
549 557
550 558
551 \LMHash{} 559 \LMHash{}
552 A variable declaration of one of the forms \code{\VAR{} $v$;}, \code{\VAR{} $ v$ = $e$;} , \code{\CONST{} $v$ = $e$;}, \code{\FINAL{} $v$;} or \code{\FINAL{} $v$ = $e$;} always induces an implicit getter function with signature 560 A variable declaration of one of the forms \code{\VAR{} $v$;}, \code{\VAR{} $ v$ = $e$;} , \code{\CONST{} $v$ = $e$;}, \code{\FINAL{} $v$;} or \code{\FINAL{} $v$ = $e$;} always induces an implicit getter function with signature
553 561
554 \GET{} $v$ 562 \GET{} $v$
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 \begin{grammar} 829 \begin{grammar}
822 {\bf defaultFormalParameter:} 830 {\bf defaultFormalParameter:}
823 normalFormalParameter (`=' expression)? 831 normalFormalParameter (`=' expression)?
824 . 832 .
825 833
826 {\bf defaultNamedParameter:}normalFormalParameter (`=' expression)?; 834 {\bf defaultNamedParameter:}normalFormalParameter (`=' expression)?;
827 normalFormalParameter ( `{\escapegrammar :}' expression)? 835 normalFormalParameter ( `{\escapegrammar :}' expression)?
828 . 836 .
829 \end{grammar} 837 \end{grammar}
830 838
831 A {\bf defaultNamedParameter} on the form: 839 A {\bf defaultNamedParameter} of the form:
832 \begin{code} 840 \begin{code}
833 normalFormalParameter : expression 841 normalFormalParameter : expression
834 \end{code} 842 \end{code}
835 is equivalent to one on the form: 843 is equivalent to one of the form:
836 \begin{code} 844 \begin{code}
837 normalFormalParameter = expression 845 normalFormalParameter = expression
838 \end{code} 846 \end{code}
839 The colon-syntax is included only for backwards compatibility. 847 The colon-syntax is included only for backwards compatibility.
840 It is deprecated and will be removed in a later version of the language specific ation. 848 It is deprecated and will be removed in a later version of the language specific ation.
841 849
842 \LMHash{} 850 \LMHash{}
843 It is a compile-time error if the default value of an optional parameter is not a compile-time constant (\ref{constants}). If no default is explicitly specified for an optional parameter an implicit default of \NULL{} is provided. 851 It is a compile-time error if the default value of an optional parameter is not a compile-time constant (\ref{constants}). If no default is explicitly specified for an optional parameter an implicit default of \NULL{} is provided.
844 852
845 \LMHash{} 853 \LMHash{}
(...skipping 3109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3955 3963
3956 If $e_f$ is a property extraction expression (\ref{propertyExtraction}), then $i $ isn't a function expression invocation and is instead recognized as an ordinar y method invocation (\ref{ordinaryInvocation}). 3964 If $e_f$ is a property extraction expression (\ref{propertyExtraction}), then $i $ isn't a function expression invocation and is instead recognized as an ordinar y method invocation (\ref{ordinaryInvocation}).
3957 3965
3958 \commentary{ 3966 \commentary{
3959 \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on objec t \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed b y a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, t he two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invoc ation} passed to \code{noSuchMethod()} would describe a call to a method \code{$ b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b $} (with no arguments) in the latter. 3967 \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on objec t \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed b y a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, t he two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invoc ation} passed to \code{noSuchMethod()} would describe a call to a method \code{$ b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b $} (with no arguments) in the latter.
3960 } 3968 }
3961 3969
3962 \LMHash{} 3970 \LMHash{}
3963 Otherwise: 3971 Otherwise:
3964 3972
3965 A function expression invocation $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldot s , x_{n+k}: a_{n+k})$ is equivalent to $e_f.call(a_1, \ldots , a_n, x_{n+1}: a_ {n+1}, \ldots , x_{n+k}: a_{n+k})$. 3973 Execution of a function expression invocation $e_f(a_1, \ldots , a_n, x_{n+1}: a _{n+1}, \ldots , x_{n+k}: a_{n+k})$ is equivalent to execution of $e_f.call(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3966 3974
3967 \commentary{ 3975 \commentary{
3968 The implication of this definition, and the other definitions involving the meth od \code{call()}, is that user defined types can be used as function values prov ided they define a \CALL{} method. The method \CALL{} is special in this regard. The signature of the \CALL{} method determines the signature used when using th e object via the built-in invocation syntax. 3976 The implication of this definition, and the other definitions involving the meth od \code{call()}, is that user defined types can be used as function values prov ided they define a \CALL{} method. The method \CALL{} is special in this regard. The signature of the \CALL{} method determines the signature used when using th e object via the built-in invocation syntax.
3969 } 3977 }
3970 3978
3971 \LMHash{} 3979 \LMHash{}
3972 It is a static warning if the static type $F$ of $e_f$ may not be assigned to a function type. If $F$ is not a function type, the static type of $i$ is \DYNAMI C{}. Otherwise 3980 It is a static warning if the static type $F$ of $e_f$ may not be assigned to a function type. If $F$ is not a function type, the static type of $i$ is \DYNAMI C{}. Otherwise
3973 the static type of $i$ is the declared return type of $F$. 3981 the static type of $i$ is the declared return type of $F$.
3974 %\item Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static war ning if $F$ is not a supertype of $(T_1, \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldot s, T_{n+k}$ $x_{n+k}]) \to \bot$. 3982 %\item Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static war ning if $F$ is not a supertype of $(T_1, \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldot s, T_{n+k}$ $x_{n+k}]) \to \bot$.
3975 %\end{itemize} 3983 %\end{itemize}
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
4889 \LMHash{} 4897 \LMHash{}
4890 An {\em equality expression} is either a relational expression (\ref{relationalE xpressions}), or an invocation of an equality operator on either \SUPER{} or an expression $e_1$, with argument $e_2$. 4898 An {\em equality expression} is either a relational expression (\ref{relationalE xpressions}), or an invocation of an equality operator on either \SUPER{} or an expression $e_1$, with argument $e_2$.
4891 4899
4892 4900
4893 \LMHash{} 4901 \LMHash{}
4894 Evaluation of an equality expression $ee$ of the form \code{$e_1$ == $e_2$} proc eeds as follows: 4902 Evaluation of an equality expression $ee$ of the form \code{$e_1$ == $e_2$} proc eeds as follows:
4895 \begin{itemize} 4903 \begin{itemize}
4896 \item The expression $e_1$ is evaluated to an object $o_1$. 4904 \item The expression $e_1$ is evaluated to an object $o_1$.
4897 \item The expression $e_2$ is evaluated to an object $o_2$. 4905 \item The expression $e_2$ is evaluated to an object $o_2$.
4898 \item If either $o_1$ or $o_2$ is \NULL{}, then $ee$ evaluates to \TRUE{} if bot h $o_1$ and $o_2$ are \NULL{} and to \FALSE{} otherwise. Otherwise, 4906 \item If either $o_1$ or $o_2$ is \NULL{}, then $ee$ evaluates to \TRUE{} if bot h $o_1$ and $o_2$ are \NULL{} and to \FALSE{} otherwise. Otherwise,
4899 \item $ee$ is equivalent to the method invocation \code{$o_1$.==($o_2$)}. 4907 \item evaluation of $ee$ is equivalent to the method invocation \code{$o_1$.==($ o_2$)}.
4900 \end{itemize} 4908 \end{itemize}
4901 4909
4902 4910
4903 \LMHash{} 4911 \LMHash{}
4904 Evaluation of an equality expression $ee$ of the form \code{\SUPER{} == $e$} pro ceeds as follows: 4912 Evaluation of an equality expression $ee$ of the form \code{\SUPER{} == $e$} pro ceeds as follows:
4905 \begin{itemize} 4913 \begin{itemize}
4906 \item The expression $e$ is evaluated to an object $o$. 4914 \item The expression $e$ is evaluated to an object $o$.
4907 \item If either \THIS{} or $o$ is \NULL{}, then $ee$ evaluates to evaluates to \ TRUE{} if both \THIS{} and $o$ are \NULL{} and to \FALSE{} otherwise. Otherwise, 4915 \item If either \THIS{} or $o$ is \NULL{}, then $ee$ evaluates to evaluates to \ TRUE{} if both \THIS{} and $o$ are \NULL{} and to \FALSE{} otherwise. Otherwise,
4908 \item $ee$ is equivalent to the method invocation \code{\SUPER{}.==($o$)}. 4916 \item evaluation of $ee$ is equivalent to the method invocation \code{\SUPER{}.= =($o$)}.
4909 \end{itemize} 4917 \end{itemize}
4910 4918
4911 \commentary{As a result of the above definition, user defined \code{==} methods can assume that their argument is non-null, and avoid the standard boiler-plate prelude: 4919 \commentary{As a result of the above definition, user defined \code{==} methods can assume that their argument is non-null, and avoid the standard boiler-plate prelude:
4912 4920
4913 \code{if (identical(\NULL{}, arg)) return \FALSE{};} 4921 \code{if (identical(\NULL{}, arg)) return \FALSE{};}
4914 4922
4915 Another implication is that there is never a need to use \code{identical()} to t est against \NULL{}, nor should anyone ever worry about whether to write \NULL{} == $e$ or $e$ == \NULL{}. 4923 Another implication is that there is never a need to use \code{identical()} to t est against \NULL{}, nor should anyone ever worry about whether to write \NULL{} == $e$ or $e$ == \NULL{}.
4916 } 4924 }
4917 4925
4918 \LMHash{} 4926 \LMHash{}
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4974 {\bf bitwiseOperator:}`\&'; 4982 {\bf bitwiseOperator:}`\&';
4975 `\^{}'; 4983 `\^{}';
4976 `$|$' 4984 `$|$'
4977 . 4985 .
4978 \end{grammar} 4986 \end{grammar}
4979 4987
4980 \LMHash{} 4988 \LMHash{}
4981 A {\em bitwise expression} is either a shift expression (\ref{shift}), or an inv ocation of a bitwise operator on either \SUPER{} or an expression $e_1$, with ar gument $e_2$. 4989 A {\em bitwise expression} is either a shift expression (\ref{shift}), or an inv ocation of a bitwise operator on either \SUPER{} or an expression $e_1$, with ar gument $e_2$.
4982 4990
4983 \LMHash{} 4991 \LMHash{}
4984 A bitwise expression of the form $e_1$ $op$ $e_2$ is equivalent to the method invocation $e_1.op(e_2)$. 4992 A bitwise expression of the form \code{$e_1$ $op$ $e_2$} is equivalent to the me thod invocation $e_1.op(e_2)$.
4985 A bitwise expression of the form \code{\SUPER{} $op$ $e_2$} is equivalent to th e method invocation \code{\SUPER{}.op($e_2$)}. 4993 A bitwise expression of the form \code{\SUPER{} $op$ $e_2$} is equivalent to the method invocation \code{\SUPER{}.$op$($e_2$)}.
4986 4994
4987 \commentary{ 4995 \commentary{
4988 It should be obvious that the static type rules for these expressions are define d by the equivalence above - ergo, by the type rules for method invocation and t he signatures of the operators on the type $e_1$. The same holds in similar situ ations throughout this specification. 4996 It should be obvious that the static type rules for these expressions are define d by the equivalence above - ergo, by the type rules for method invocation and t he signatures of the operators on the type $e_1$. The same holds in similar situ ations throughout this specification.
4989 } 4997 }
4990 4998
4991 4999
4992 \subsection{ Shift} 5000 \subsection{ Shift}
4993 \LMLabel{shift} 5001 \LMLabel{shift}
4994 5002
4995 \LMHash{} 5003 \LMHash{}
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
5103 {\bf tildeOperator:} `\~{}' 5111 {\bf tildeOperator:} `\~{}'
5104 . 5112 .
5105 5113
5106 5114
5107 \end{grammar} 5115 \end{grammar}
5108 5116
5109 \LMHash{} 5117 \LMHash{}
5110 A {\em unary expression} is either a postfix expression (\ref{postfixExpression s}), an await expression (\ref{awaitExpressions}) or an invocation of a prefix o perator on an expression or an invocation of a unary operator on either \SUPER{} or an expression $e$. 5118 A {\em unary expression} is either a postfix expression (\ref{postfixExpression s}), an await expression (\ref{awaitExpressions}) or an invocation of a prefix o perator on an expression or an invocation of a unary operator on either \SUPER{} or an expression $e$.
5111 5119
5112 \LMHash{} 5120 \LMHash{}
5113 The expression $!e$ is equivalent to the expression $e?$ $ \FALSE{} :\TRUE{}$. 5121 The expression $!e$ is equivalent to the expression \code{$e$ ? \FALSE{} : \TRUE {}}.
5114 5122
5115 \LMHash{} 5123 \LMHash{}
5116 Evaluation of an expression of the form \code{++$e$} is equivalent to \code{$e$ += 1}. Evaluation of an expression of the form \code{-{}-$e$} is equivalent to \code{$e$ -= 1}. 5124 Evaluation of an expression of the form \code{++$e$} is equivalent to \code{$e$ += 1}. Evaluation of an expression of the form \code{-{}-$e$} is equivalent to \code{$e$ -= 1}.
5117 5125
5118 %The expression $-e$ is equivalent to the method invocation \code{$e$.-()}. The expression \code{-\SUPER{}} is equivalent to the method invocation \code{\SUPE R{}.-()}. 5126 %The expression $-e$ is equivalent to the method invocation \code{$e$.-()}. The expression \code{-\SUPER{}} is equivalent to the method invocation \code{\SUPE R{}.-()}.
5119 5127
5120 \LMHash{} 5128 \LMHash{}
5121 An expression of the form \code{$op$ $e$} is equivalent to the method invocation \code{$e.op()$}. An expression of the form \code{$op$ \SUPER{}} is equivalent t o the method invocation (\ref{superInvocation}) \code{\SUPER{}.$op()$}. 5129 An expression of the form \code{$op$ $e$} is equivalent to the method invocation \code{$e.op()$}. An expression of the form \code{$op$ \SUPER{}} is equivalent t o the method invocation (\ref{superInvocation}) \code{\SUPER{}.$op()$}.
5122 5130
5123 \subsection{ Await Expressions} 5131 \subsection{ Await Expressions}
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
5308 Evaluate \code{$a$[$i$]} to an object $r$ 5316 Evaluate \code{$a$[$i$]} to an object $r$
5309 and let $y$ be a fresh variable bound to $r$. 5317 and let $y$ be a fresh variable bound to $r$.
5310 Evaluate \code{$a$[$i$] = $y$ - 1}. 5318 Evaluate \code{$a$[$i$] = $y$ - 1}.
5311 Then $e$ evaluates to $r$. 5319 Then $e$ evaluates to $r$.
5312 5320
5313 \LMHash{} 5321 \LMHash{}
5314 The static type of such an expression is the static type of \code{$e_1$[$e_2$]}. 5322 The static type of such an expression is the static type of \code{$e_1$[$e_2$]}.
5315 5323
5316 \LMHash{} 5324 \LMHash{}
5317 Evaluation of a postfix expression $e$ of the form \code{$e_1$?.$v$++} 5325 Evaluation of a postfix expression $e$ of the form \code{$e_1$?.$v$++}
5318 where $e_1$ is not a type literal, proceeds as follows: 5326 proceeds as follows:
5319 5327
5320 \LMHash{} 5328 \LMHash{}
5321 If $e_1$ is a type literal, $e$ is equivalent to \code{$e_1$.$v$++}. 5329 If $e_1$ is a type literal, evaluation of $e$ is equivalent to
5330 evaluation of \code{$e_1$.$v$++}.
5322 5331
5323 \LMHash{} 5332 \LMHash{}
5324 Otherwise evaluate $e_1$ to an object $u$. 5333 Otherwise evaluate $e_1$ to an object $u$.
5325 if $u$ is the null value, $e$ evaluates to the null value. 5334 if $u$ is the null value, $e$ evaluates to the null value.
5326 Otherwise let $x$ be a fresh variable bound to $u$. 5335 Otherwise let $x$ be a fresh variable bound to $u$.
5327 Evaluate \code{$x$.$v$++} to an object $o$. 5336 Evaluate \code{$x$.$v$++} to an object $o$.
5328 Then $e$ evaluates to $o$. 5337 Then $e$ evaluates to $o$.
5329 5338
5330 \LMHash{} 5339 \LMHash{}
5331 The static type of such an expression is the static type of \code{$e_1$.$v$}. 5340 The static type of such an expression is the static type of \code{$e_1$.$v$}.
5332 5341
5333 \LMHash{} 5342 \LMHash{}
5334 Evaluation of a postfix expression $e$ of the form \code{$e_1$?.$v$-{}-} 5343 Evaluation of a postfix expression $e$ of the form \code{$e_1$?.$v$-{}-}
5335 where $e_1$ is not a type literal, proceeds as follows: 5344 proceeds as follows:
5336 5345
5337 If $e_1$ is a type literal, $e$ is equivalent to \code{$e_1$.$v$-{}-}. 5346 If $e_1$ is a type literal, evaluation of $e$ is equivalent to
5347 evaluation of \code{$e_1$.$v$-{}-}.
5338 5348
5339 Otherwise evaluate $e_1$ to an object $u$. 5349 Otherwise evaluate $e_1$ to an object $u$.
5340 If $u$ is the null value, $e$ evaluates to the null value. 5350 If $u$ is the null value, $e$ evaluates to the null value.
5341 Otherwise let $x$ be a fresh variable bound to $u$. 5351 Otherwise let $x$ be a fresh variable bound to $u$.
5342 Evaluate \code{$x$.$v$-{}-} to an object $o$. 5352 Evaluate \code{$x$.$v$-{}-} to an object $o$.
5343 Then $e$ evaluates to $o$. 5353 Then $e$ evaluates to $o$.
5344 5354
5345 5355
5346 \LMHash{} 5356 \LMHash{}
5347 The static type of such an expression is the static type of \code{$e_1$.$v$}. 5357 The static type of such an expression is the static type of \code{$e_1$.$v$}.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5396 \LMHash{} 5406 \LMHash{}
5397 An assignable expression of the form $e.id$ or $e?.id$ is evaluated as a propert y extraction (\ref{propertyExtraction}). 5407 An assignable expression of the form $e.id$ or $e?.id$ is evaluated as a propert y extraction (\ref{propertyExtraction}).
5398 5408
5399 \LMHash{} 5409 \LMHash{}
5400 An assignable expression of the form \code{$e_1$[$e_2$]} is evaluated as a metho d invocation of the operator method \code{[]} on $e_1$ with argument $e_2$. 5410 An assignable expression of the form \code{$e_1$[$e_2$]} is evaluated as a metho d invocation of the operator method \code{[]} on $e_1$ with argument $e_2$.
5401 5411
5402 \LMHash{} 5412 \LMHash{}
5403 An assignable expression of the form \code{\SUPER{}.id} is evaluated as a prope rty extraction. 5413 An assignable expression of the form \code{\SUPER{}.id} is evaluated as a prope rty extraction.
5404 5414
5405 \LMHash{} 5415 \LMHash{}
5406 An assignable expression of the form \code{\SUPER{}[$e_2$]} is equivalent to the method invocation \code{\SUPER{}.[]($e_2$)}. 5416 Evaluation of an assignable expression of the form \code{\SUPER{}[$e_2$]} is equ ivalent to evaluation of the method invocation \code{\SUPER{}.[]($e_2$)}.
5407 5417
5408 \subsection{ Identifier Reference} 5418 \subsection{ Identifier Reference}
5409 \LMLabel{identifierReference} 5419 \LMLabel{identifierReference}
5410 5420
5411 \LMHash{} 5421 \LMHash{}
5412 An {\em identifier expression} consists of a single identifier; it provides acce ss to an object via an unqualified name. 5422 An {\em identifier expression} consists of a single identifier; it provides acce ss to an object via an unqualified name.
5413 5423
5414 \begin{grammar} 5424 \begin{grammar}
5415 {\bf identifier:} 5425 {\bf identifier:}
5416 IDENTIFIER 5426 IDENTIFIER
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5497 %\item If $d$ is a library variable then: 5507 %\item If $d$ is a library variable then:
5498 % \begin{itemize} 5508 % \begin{itemize}
5499 % \item If $d$ is of one of the forms \code{\VAR{} $v$ = $e_i$;} , \code{$T$ $v $ = $e_i$;} , \code{\FINAL{} $v$ = $e_i$;} or \code{\FINAL{} $T$ $v$ = $e_i$;} and no value has yet been stored into $v$ then the initializer expression $e_i$ is evaluated. If, during the evaluation of $e_i$, the getter for $v$ is referenc ed, a \code{CyclicInitializationError} is thrown. If the evaluation succeeded yi elding an object $o$, let $r = o$, otherwise let $r = \NULL{}$. In any case, $r$ is stored into $v$. The value of $e$ is $r$. 5509 % \item If $d$ is of one of the forms \code{\VAR{} $v$ = $e_i$;} , \code{$T$ $v $ = $e_i$;} , \code{\FINAL{} $v$ = $e_i$;} or \code{\FINAL{} $T$ $v$ = $e_i$;} and no value has yet been stored into $v$ then the initializer expression $e_i$ is evaluated. If, during the evaluation of $e_i$, the getter for $v$ is referenc ed, a \code{CyclicInitializationError} is thrown. If the evaluation succeeded yi elding an object $o$, let $r = o$, otherwise let $r = \NULL{}$. In any case, $r$ is stored into $v$. The value of $e$ is $r$.
5500 \item If $d$ is a constant variable of one of the forms \code{\CONST{} $v$ = $e$;} or \code{\CONST{} $T$ $v$ = $e$;} then the value $id$ is the value of the compile-time constant $e$. 5510 \item If $d$ is a constant variable of one of the forms \code{\CONST{} $v$ = $e$;} or \code{\CONST{} $T$ $v$ = $e$;} then the value $id$ is the value of the compile-time constant $e$.
5501 % Otherwise 5511 % Otherwise
5502 % \item $e$ evaluates to the current binding of $id$. 5512 % \item $e$ evaluates to the current binding of $id$.
5503 % \end{itemize} 5513 % \end{itemize}
5504 \item If $d$ is a local variable or formal parameter then $e$ evaluates to the c urrent binding of $id$. 5514 \item If $d$ is a local variable or formal parameter then $e$ evaluates to the c urrent binding of $id$.
5505 %\item If $d$ is a library variable, local variable, or formal parameter, then $ e$ evaluates to the current binding of $id$. \commentary{This case also applies if d is a library or local function declaration, as these are equivalent to func tion-valued variable declarations.} 5515 %\item If $d$ is a library variable, local variable, or formal parameter, then $ e$ evaluates to the current binding of $id$. \commentary{This case also applies if d is a library or local function declaration, as these are equivalent to func tion-valued variable declarations.}
5506 \item If $d$ is a static method, top-level function or local function then $e$ e valuates to the function defined by $d$. 5516 \item If $d$ is a static method, top-level function or local function then $e$ e valuates to the function defined by $d$.
5507 \item If $d$ is the declaration of a static variable, static getter or static se tter declared in class $C$, then $e$ is equivalent to the property extraction (\ ref{propertyExtraction}) $C.id$. 5517 \item If $d$ is the declaration of a static variable, static getter or static se tter declared in class $C$, then evaluation of $e$ is equivalent to evaluation o f the property extraction (\ref{propertyExtraction}) $C.id$.
5508 \item If $d$ is the declaration of a library variable, top-level getter or top-l evel setter, then $e$ is equivalent to the top level getter invocation (\ref{top LevelGetterInvocation}) $id$. 5518 \item If $d$ is the declaration of a library variable, top-level getter or top-l evel setter, then evaluation of $e$ is equivalent to evaluation of the top level getter invocation (\ref{topLevelGetterInvocation}) $id$.
5509 \item Otherwise, if $e$ occurs inside a top level or static function (be it func tion, method, getter, or setter) or variable initializer, evaluation of $e$ cau ses a \code{NoSuchMethod} to be thrown. 5519 \item Otherwise, if $e$ occurs inside a top level or static function (be it func tion, method, getter, or setter) or variable initializer, evaluation of $e$ cau ses a \code{NoSuchMethod} to be thrown.
5510 \item Otherwise, $e$ is equivalent to the property extraction (\ref{propertyExtr action}) \THIS{}.$id$. 5520 \item Otherwise, evaluation of $e$ is equivalent to evaluation of the property e xtraction (\ref{propertyExtraction}) \THIS{}.$id$.
5511 % This implies that referring to an undefined static getter by simple name is an error, whereas doing so by qualified name is only a warning. Same with assignme nts. Revise? 5521 % This implies that referring to an undefined static getter by simple name is an error, whereas doing so by qualified name is only a warning. Same with assignme nts. Revise?
5512 \end{itemize} 5522 \end{itemize}
5513 5523
5514 \LMHash{} 5524 \LMHash{}
5515 The static type of $e$ is determined as follows: 5525 The static type of $e$ is determined as follows:
5516 5526
5517 \begin{itemize} 5527 \begin{itemize}
5518 \item If $d$ is a class, type alias or type parameter the static type of $e$ is \code{Type}. 5528 \item If $d$ is a class, type alias or type parameter the static type of $e$ is \code{Type}.
5519 \item If $d$ is a local variable or formal parameter the static type of $e$ is t he type of the variable $id$, unless $id$ is known to have some type $T$, in whi ch case the static type of $e$ is $T$, provided that $T$ is more specific than a ny other type $S$ such that $v$ is known to have type $S$. 5529 \item If $d$ is a local variable or formal parameter the static type of $e$ is t he type of the variable $id$, unless $id$ is known to have some type $T$, in whi ch case the static type of $e$ is $T$, provided that $T$ is more specific than a ny other type $S$ such that $v$ is known to have type $S$.
5520 \item If $d$ is a static method, top-level function or local function the static type of $e$ is the function type defined by $d$. 5530 \item If $d$ is a static method, top-level function or local function the static type of $e$ is the function type defined by $d$.
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
5726 \begin{grammar} 5736 \begin{grammar}
5727 {\bf localVariableDeclaration:} 5737 {\bf localVariableDeclaration:}
5728 initializedVariableDeclaration `{\escapegrammar ;}' 5738 initializedVariableDeclaration `{\escapegrammar ;}'
5729 . 5739 .
5730 \end{grammar} 5740 \end{grammar}
5731 5741
5732 \LMHash{} 5742 \LMHash{}
5733 Executing a variable declaration statement of one of the forms \VAR{} $v = e;$ , $T$ $v = e; $, \CONST{} $v = e;$, \CONST{} $T$ $v = e;$, \FINAL{} $v = e;$ o r \FINAL{} $T$ $v = e;$ proceeds as follows: 5743 Executing a variable declaration statement of one of the forms \VAR{} $v = e;$ , $T$ $v = e; $, \CONST{} $v = e;$, \CONST{} $T$ $v = e;$, \FINAL{} $v = e;$ o r \FINAL{} $T$ $v = e;$ proceeds as follows:
5734 5744
5735 \LMHash{} 5745 \LMHash{}
5736 The expression $e$ is evaluated to an object $o$. Then, the variable $v$ is set to $o$. 5746 The expression $e$ is evaluated to an object $o$. Then, the variable $v$ is set to $o$.
5737 5747
5738 \LMHash{} 5748 \LMHash{}
5739 A variable declaration statement of the form \VAR{} $v;$ is equivalent to \VAR{ } $v = \NULL{};$. A variable declaration statement of the form $T$ $v;$ is equiv alent to $T$ $v = \NULL{};$. 5749 A variable declaration statement of the form \code{\VAR{} $v$;} is equivalent to \code{\VAR{} $v$ = \NULL{};}. A variable declaration statement of the form \cod e{$T$ $v$;} is equivalent to \code{$T$ $v$ = \NULL{};}.
5740 5750
5741 \commentary{ 5751 \commentary{
5742 This holds regardless of the type $T$. For example, \code{int i;} does not cause \code{i} to be initialized to zero. Instead, \code{i} is initialized to \NULL{} , just as if we had written \VAR{} \code{i;} or \code{Object i;} or \code{Collec tion<String> i;}. 5752 This holds regardless of the type $T$. For example, \code{int i;} does not cause \code{i} to be initialized to zero. Instead, \code{i} is initialized to \NULL{} , just as if we had written \VAR{} \code{i;} or \code{Object i;} or \code{Collec tion<String> i;}.
5743 } 5753 }
5744 5754
5745 \rationale{ 5755 \rationale{
5746 To do otherwise would undermine the optionally typed nature of Dart, causing typ e annotations to modify program behavior. 5756 To do otherwise would undermine the optionally typed nature of Dart, causing typ e annotations to modify program behavior.
5747 } 5757 }
5748 5758
5749 %A variable declaration statement of one of the forms $T$ $v;$, $T$ $v = e;$, \C ONST{} $T$ $v = e;$, or \FINAL{} $T$ $v = e;$ causes a new getter named $v$ wit h static return type $T$ to be added to the innermost enclosing scope at the poi nt following the variable declaration statement. The result of executing this ge tter is the value stored in $v$. 5759 %A variable declaration statement of one of the forms $T$ $v;$, $T$ $v = e;$, \C ONST{} $T$ $v = e;$, or \FINAL{} $T$ $v = e;$ causes a new getter named $v$ wit h static return type $T$ to be added to the innermost enclosing scope at the poi nt following the variable declaration statement. The result of executing this ge tter is the value stored in $v$.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
5818 \LMLabel{if} 5828 \LMLabel{if}
5819 5829
5820 \LMHash{} 5830 \LMHash{}
5821 The {\em if statement} allows for conditional execution of statements. 5831 The {\em if statement} allows for conditional execution of statements.
5822 5832
5823 \begin{grammar} 5833 \begin{grammar}
5824 {\bf ifStatement:} 5834 {\bf ifStatement:}
5825 \IF{} `(' expression `)' statement ( \ELSE{} statement)? 5835 \IF{} `(' expression `)' statement ( \ELSE{} statement)?
5826 . 5836 .
5827 \end{grammar} 5837 \end{grammar}
5838 An if statement of the form \code{\IF{} ($e$) $s_1$ \ELSE{} $s_2$} where $s_1$ i s not a block statement is equivalent to the statement \code{\IF{} ($e$) \{$s_1$ \} \ELSE{} $s_2$}.
5839 An if statement of the form \code{\IF{} ($e$) $s_1$ \ELSE{} $s_2$} where $s_2$ i s not a block statement is equivalent to the statement \code{\IF{} ($e$) $s_1$ \ ELSE{} \{$s_2$\}}.
5828 5840
5829 Execution of an if statement of the form \code {\IF{} (}$b$\code{)}$s_1$ \code{ \ELSE{} } $s_2$ proceeds as follows: 5841 \rationale {
5830 5842 The reason for this equivalence is to catch errors such as
5831 \LMHash{} 5843 }
5832 First, the expression $b$ is evaluated to an object $o$. Then, $o$ is subjected to boolean conversion (\ref{booleanConversion}), producing an object $r$. If $r $ is \TRUE{}, then the statement $\{s_1\}$ is executed, otherwise statement $\{s _2\}$ is executed. 5844 \begin{dartCode}
5833
5834 \commentary {
5835 Put another way, \code {\IF{} (}$b$\code{)}$s_1$ \code{\ELSE{} } $s_2$ is equiv alent to
5836 \code {\IF{} (}$b$\code{)}$\{s_1\}$ \code{\ELSE{} } $\{s_2\}$
5837 }
5838
5839 \rationale {
5840 The reason for this equivalence is to catch errors such as
5841 }
5842 \begin{dartCode}
5843 \VOID{} main() \{ 5845 \VOID{} main() \{
5844 \IF{} (somePredicate) 5846 \IF{} (somePredicate)
5845 \VAR{} v = 2; 5847 \VAR{} v = 2;
5846 print(v); 5848 print(v);
5847 \} 5849 \}
5848 \end{dartCode} 5850 \end{dartCode}
5849 5851
5850 \rationale { 5852 \rationale {
5851 Under reasonable scope rules such code is problematic. If we assume that \code{ v} is declared in the scope of the method \code{main()}, then when \code{somePre dicate} is false, \code{v} will be uninitialized when accessed. The cleanest ap proach would be to require a block following the test, rather than an arbitrary statement. However, this goes against long standing custom, undermining Dart's g oal of familiarity. Instead, we choose to insert a block, introducing a scope, around the statement following the predicate (and similarly for \ELSE{} and loo ps). This will cause both a warning and a runtime error in the case above. Of c ourse, if there is a declaration of \code{v} in the surrounding scope, programme rs might still be surprised. We expect tools to highlight cases of shadowing to help avoid such situations. 5853 Under reasonable scope rules such code is problematic. If we assume that \code{ v} is declared in the scope of the method \code{main()}, then when \code{somePre dicate} is false, \code{v} will be uninitialized when accessed. The cleanest ap proach would be to require a block following the test, rather than an arbitrary statement. However, this goes against long standing custom, undermining Dart's g oal of familiarity. Instead, we choose to insert a block, introducing a scope, around the statement following the predicate (and similarly for \ELSE{} and loo ps). This will cause both a warning and a runtime error in the case above. Of c ourse, if there is a declaration of \code{v} in the surrounding scope, programme rs might still be surprised. We expect tools to highlight cases of shadowing to help avoid such situations.
5852 } 5854 }
5855
5853 5856
5854 \LMHash{} 5857 \LMHash{}
5855 It is a static type warning if the type of the expression $b$ may not be assig ned to \code{bool}. 5858 Execution of an if statement of the form \code{\IF{} ($b$) $s_1$ \ELSE{} $s_2$} where $s_1$ and $s_2$ are block statements, proceeds as follows:
5859
5860 \LMHash{}
5861 First, the expression $b$ is evaluated to an object $o$. Then, $o$ is subjected to boolean conversion (\ref{booleanConversion}), producing an object $r$. If $r$ is \TRUE{}, then the block statement $s_1$ is executed, otherwise the block sta tement $s_2$ is executed.
5862
5863 \LMHash{}
5864 It is a static type warning if the type of the expression $b$ may not be assigne d to \code{bool}.
5856 5865
5857 \LMHash{} 5866 \LMHash{}
5858 If: 5867 If:
5859 \begin{itemize} 5868 \begin{itemize}
5860 \item $b$ shows that a variable $v$ has type $T$. 5869 \item $b$ shows that a variable $v$ has type $T$.
5861 \item $v$ is not potentially mutated in $s_1$ or within a closure. 5870 \item $v$ is not potentially mutated in $s_1$ or within a closure.
5862 \item If the variable $v$ is accessed by a closure in $s_1$ then the variable $v $ is not potentially mutated anywhere in the scope of $v$. 5871 \item If the variable $v$ is accessed by a closure in $s_1$ then the variable $v $ is not potentially mutated anywhere in the scope of $v$.
5863 \end{itemize} 5872 \end{itemize}
5864 then the type of $v$ is known to be $T$ in $s_1$. 5873 then the type of $v$ is known to be $T$ in $s_1$.
5865 5874
5866 \LMHash{} 5875 \LMHash{}
5867 An if statement of the form \code {\IF{} (}$b$\code{)}$s_1$ is equivalent to t he if statement 5876 An if statement of the form \code{\IF{} ($e$) $s$} is equivalent to the if state ment \code{\IF{} ($e$) $s$ \ELSE{} \{\}}.
5868
5869 \code {\IF{} (}$b$\code{)}$s_1$ \code{\ELSE{} \{\}}.
5870
5871 5877
5872 5878
5873 \subsection{For} 5879 \subsection{For}
5874 \LMLabel{for} 5880 \LMLabel{for}
5875 5881
5876 \LMHash{} 5882 \LMHash{}
5877 The {\em for statement} supports iteration. 5883 The {\em for statement} supports iteration.
5878 5884
5879 \begin{grammar} 5885 \begin{grammar}
5880 {\bf forStatement:} 5886 {\bf forStatement:}
(...skipping 11 matching lines...) Expand all
5892 \end{grammar} 5898 \end{grammar}
5893 5899
5894 \LMHash{} 5900 \LMHash{}
5895 The for statement has three forms - the traditional for loop and two forms of t he for-in statement - synchronous and asynchronous. 5901 The for statement has three forms - the traditional for loop and two forms of t he for-in statement - synchronous and asynchronous.
5896 5902
5897 \subsubsection{For Loop} 5903 \subsubsection{For Loop}
5898 \LMLabel{forLoop} 5904 \LMLabel{forLoop}
5899 5905
5900 5906
5901 \LMHash{} 5907 \LMHash{}
5902 Execution of a for statement of the form \code{ \FOR{} (\VAR{} $v$ = $e_0$ ; $ c$; $e$) $s$} proceeds as follows: 5908 Execution of a for statement of the form \code{ \FOR{} (\VAR{} $v$ = $e_0$ ; $c$ ; $e$) $s$} proceeds as follows:
5903 5909
5904 \LMHash{} 5910 \LMHash{}
5905 If $c$ is empty then let $c^\prime$ be \TRUE{} otherwise let $c^\prime$ be $c$. 5911 If $c$ is empty then let $c^\prime$ be \TRUE{} otherwise let $c^\prime$ be $c$.
5906 5912
5907 \LMHash{} 5913 \LMHash{}
5908 First the variable declaration statement \VAR{} $v = e_0$ is executed. Then: 5914 First the variable declaration statement \VAR{} $v = e_0$ is executed. Then:
5909 \begin{enumerate} 5915 \begin{enumerate}
5910 \item 5916 \item
5911 \label{beginFor} 5917 \label{beginFor}
5912 If this is the first iteration of the for loop, let $v^\prime$ be $v$. Otherwise , let $v^\prime$ be the variable $v^{\prime\prime}$ created in the previous exe cution of step \ref{allocateFreshVar}. 5918 If this is the first iteration of the for loop, let $v^\prime$ be $v$. Otherwise , let $v^\prime$ be the variable $v^{\prime\prime}$ created in the previous exe cution of step \ref{allocateFreshVar}.
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
6403 6409
6404 \LMHash{} 6410 \LMHash{}
6405 An \ON{}-\CATCH{} clause of the form \code{\CATCH{} ($p$) $s$} is equivalent to an \ON{}-\CATCH{} clause \code{\ON{} \DYNAMIC{} \CATCH{} ($p$, $p_2$) $s$} wher e $p_2$ is a fresh identifier. 6411 An \ON{}-\CATCH{} clause of the form \code{\CATCH{} ($p$) $s$} is equivalent to an \ON{}-\CATCH{} clause \code{\ON{} \DYNAMIC{} \CATCH{} ($p$, $p_2$) $s$} wher e $p_2$ is a fresh identifier.
6406 6412
6407 An \ON{}-\CATCH{} clause of the form \code{\CATCH{} ($p_1$, $p_2$) $s$} is equiv alent to an \ON{}-\CATCH{} clause \code{\ON{} \DYNAMIC{} \CATCH{} ($p_1$, $p_2$) $s$}. 6413 An \ON{}-\CATCH{} clause of the form \code{\CATCH{} ($p_1$, $p_2$) $s$} is equiv alent to an \ON{}-\CATCH{} clause \code{\ON{} \DYNAMIC{} \CATCH{} ($p_1$, $p_2$) $s$}.
6408 6414
6409 \LMHash{} 6415 \LMHash{}
6410 An \ON{}-\CATCH{} clause of the form \code{\ON{} $T$ \CATCH{} ($p_1$, $p_2$) $ s$} introduces a new scope $CS$ in which final local variables specified by $p_1 $ and $p_2$ are defined. The statement $s$ is enclosed within $CS$. The static t ype of $p_1$ is $T$ and the static type of $p_2$ is \code{StackTrace}. 6416 An \ON{}-\CATCH{} clause of the form \code{\ON{} $T$ \CATCH{} ($p_1$, $p_2$) $ s$} introduces a new scope $CS$ in which final local variables specified by $p_1 $ and $p_2$ are defined. The statement $s$ is enclosed within $CS$. The static t ype of $p_1$ is $T$ and the static type of $p_2$ is \code{StackTrace}.
6411 6417
6412 \LMHash{} 6418 \LMHash{}
6413 Execution of a \TRY{} statement $s$ on the form: 6419 Execution of a \TRY{} statement $s$ of the form:
6414 \begin{dartCode} 6420 \begin{dartCode}
6415 \TRY{} $b$ 6421 \TRY{} $b$
6416 \ON{} $T_1$ \CATCH{} ($e_1$, $t_1$) $c_1$ 6422 \ON{} $T_1$ \CATCH{} ($e_1$, $t_1$) $c_1$
6417 \ldots{} 6423 \ldots{}
6418 \ON{} $T_n$ \CATCH{} ($e_n$, $t_n$) $c_n$ 6424 \ON{} $T_n$ \CATCH{} ($e_n$, $t_n$) $c_n$
6419 \FINALLY{} $f$ 6425 \FINALLY{} $f$
6420 \end{dartCode} 6426 \end{dartCode}
6421 proceeds as follows: 6427 proceeds as follows:
6422 6428
6423 \LMHash{} 6429 \LMHash{}
6424 First $b$ is executed. 6430 First $b$ is executed.
6425 If execution of $b$ throws (\ref{completion}) with exception object $e$ and stac k trace $t$, then $e$ and $t$ are matched against the \ON{}-\CATCH{} clauses to yield a new completion (\ref{on-catch}). 6431 If execution of $b$ throws (\ref{completion}) with exception object $e$ and stac k trace $t$, then $e$ and $t$ are matched against the \ON{}-\CATCH{} clauses to yield a new completion (\ref{on-catch}).
6426 6432
6427 Then, even if execution of $b$ did not complete normally or matching against the \ON{}-\CATCH{} clauses did not complete normally, the $f$ block is executed. 6433 Then, even if execution of $b$ did not complete normally or matching against the \ON{}-\CATCH{} clauses did not complete normally, the $f$ block is executed.
6428 6434
6429 If execution of $f$ does not complete normally, 6435 If execution of $f$ does not complete normally,
6430 execution of the \TRY{} statement completes in the same way. 6436 execution of the \TRY{} statement completes in the same way.
6431 Otherwise if execution of $b$ threw (\ref{completion}), the \TRY{} statement com pletes in the same way as the matching against the \ON{}-\CATCH{} clauses. 6437 Otherwise if execution of $b$ threw (\ref{completion}), the \TRY{} statement com pletes in the same way as the matching against the \ON{}-\CATCH{} clauses.
6432 Otherwise the \TRY{} statement completes in the same way as the execution of $b$ . 6438 Otherwise the \TRY{} statement completes in the same way as the execution of $b$ .
6433 6439
6434 \LMHash{} 6440 \LMHash{}
6435 If $T_1$ is a malformed or deferred type (\ref{staticTypes}), then performing a match causes a run time error. 6441 If $T_1$ is a malformed or deferred type (\ref{staticTypes}), then performing a match causes a run time error.
6436 It is a static warning if $T_i$, $1 \le i \le n$ is a deferred or malformed type . 6442 It is a static warning if $T_i$, $1 \le i \le n$ is a deferred or malformed type .
6437 6443
6438 \subsubsection{\ON{}-\CATCH{} clauses} 6444 \subsubsection{\ON{}-\CATCH{} clauses}
6439 \LMLabel{on-catch} 6445 \LMLabel{on-catch}
6440 6446
6441 \LMHash{} 6447 \LMHash{}
6442 Matching an exception object $e$ and stack trace $t$ against a (potentially empt y) sequence of \ON{}-\CATCH{} clauses on the form 6448 Matching an exception object $e$ and stack trace $t$ against a (potentially empt y) sequence of \ON{}-\CATCH{} clauses of the form
6443 \begin{dartCode} 6449 \begin{dartCode}
6444 \ON{} $T_1$ \CATCH{} ($e_1$, $st_1$) \{ $s_1$ \} 6450 \ON{} $T_1$ \CATCH{} ($e_1$, $st_1$) \{ $s_1$ \}
6445 \ldots 6451 \ldots
6446 \ON{} $T_n$ \CATCH{} ($e_n$, $st_n$) \{ $s_n$ \} 6452 \ON{} $T_n$ \CATCH{} ($e_n$, $st_n$) \{ $s_n$ \}
6447 \end{dartCode} 6453 \end{dartCode}
6448 proceeds as follows: 6454 proceeds as follows:
6449 6455
6450 \LMHash{} 6456 \LMHash{}
6451 If there are no \ON{}-\CATCH{} clauses ($n = 0$), matching throws the exception object $e$ and stack trace $t$ (\ref{completion}). 6457 If there are no \ON{}-\CATCH{} clauses ($n = 0$), matching throws the exception object $e$ and stack trace $t$ (\ref{completion}).
6452 6458
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
6770 . 6776 .
6771 \end{grammar} 6777 \end{grammar}
6772 6778
6773 \LMHash{} 6779 \LMHash{}
6774 The grammar allows a trailing comma before the closing parenthesis, 6780 The grammar allows a trailing comma before the closing parenthesis,
6775 similarly to an argument list. That comma, if present, has no effect. 6781 similarly to an argument list. That comma, if present, has no effect.
6776 An assertion with a trailing comma is equivalent to one with that 6782 An assertion with a trailing comma is equivalent to one with that
6777 comma removed. 6783 comma removed.
6778 6784
6779 \LMHash{} 6785 \LMHash{}
6780 An assertion on the form \code{\ASSERT($e$))} is equivalent to an assertion on t he form \code{\ASSERT($e$, null)}. 6786 An assertion of the form \code{\ASSERT($e$))} is equivalent to an assertion of t he form \code{\ASSERT($e$, null)}.
6781 6787
6782 \LMHash{} 6788 \LMHash{}
6783 Execution of an assert statement executes the assertion as described below 6789 Execution of an assert statement executes the assertion as described below
6784 and completes in the same way as the assertion. 6790 and completes in the same way as the assertion.
6785 6791
6786 \LMHash{} 6792 \LMHash{}
6787 In production mode an assertion has no effect 6793 In production mode an assertion has no effect
6788 and its execution immediately completes normally (\ref{completion}). 6794 and its execution immediately completes normally (\ref{completion}).
6789 In checked mode, 6795 In checked mode,
6790 execution of an assertion \code{\ASSERT{}($c$, $e$)} proceeds as follows: 6796 execution of an assertion \code{\ASSERT{}($c$, $e$)} proceeds as follows:
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
8246 8252
8247 The invariant that each normative paragraph is associated with a line 8253 The invariant that each normative paragraph is associated with a line
8248 containing the text \LMHash{} should be maintained. Extra occurrences 8254 containing the text \LMHash{} should be maintained. Extra occurrences
8249 of \LMHash{} can be added if needed, e.g., in order to make 8255 of \LMHash{} can be added if needed, e.g., in order to make
8250 individual \item{}s in itemized lists addressable. Each \LM.. command 8256 individual \item{}s in itemized lists addressable. Each \LM.. command
8251 must occur on a separate line. \LMHash{} must occur immediately 8257 must occur on a separate line. \LMHash{} must occur immediately
8252 before the associated paragraph, and \LMLabel must occur immediately 8258 before the associated paragraph, and \LMLabel must occur immediately
8253 after the associated \section{}, \subsection{} etc. 8259 after the associated \section{}, \subsection{} etc.
8254 8260
8255 ---------------------------------------------------------------------- 8261 ----------------------------------------------------------------------
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