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

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

Issue 1171283002: Updates for 1.10: warnings when for-in uses an expresison that has no iterator; assorted typos. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 \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.10}}
11 11
12 % For information about Location Markers (and in particular the 12 % For information about Location Markers (and in particular the
13 % commands \LMHash and \LMLabel), see the long comment at the 13 % commands \LMHash and \LMLabel), see the long comment at the
14 % end of this file. 14 % end of this file.
15 15
16 \begin{document} 16 \begin{document}
17 \maketitle 17 \maketitle
18 \tableofcontents 18 \tableofcontents
19 19
20 20
(...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 throwExpressionWithoutCascade 2337 throwExpressionWithoutCascade
2338 . 2338 .
2339 2339
2340 {\bf expressionList:} 2340 {\bf expressionList:}
2341 expression (`,' expression)* %should these be top level expressions? 2341 expression (`,' expression)* %should these be top level expressions?
2342 . 2342 .
2343 \end{grammar} 2343 \end{grammar}
2344 2344
2345 \begin{grammar} 2345 \begin{grammar}
2346 {\bf primary:}thisExpression; 2346 {\bf primary:}thisExpression;
2347 \SUPER{} assignableSelector; 2347 \SUPER{} unconditionalAssignableSelector;
2348 functionExpression; 2348 functionExpression;
2349 literal; 2349 literal;
2350 identifier; 2350 identifier;
2351 newExpression; 2351 newExpression;
2352 \NEW{} type `\#' (`{\escapegrammar .}' identifier)?; 2352 \NEW{} type `\#' (`{\escapegrammar .}' identifier)?;
2353 constObjectExpression; 2353 constObjectExpression;
2354 `(' expression `)' 2354 `(' expression `)'
2355 . 2355 .
2356 2356
2357 \end{grammar} 2357 \end{grammar}
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2741 2741
2742 \end{grammar} 2742 \end{grammar}
2743 2743
2744 \LMHash{} 2744 \LMHash{}
2745 Multiline strings are delimited by either matching triples of single quotes or m atching triples of double quotes. If the first line of a multiline string consis ts solely of the whitespace characters defined by the production {\em WHITESPACE } \ref{lexicalRules}), possibly prefixed by $\backslash$, then that line is ign ored, including the new line at its end. 2745 Multiline strings are delimited by either matching triples of single quotes or m atching triples of double quotes. If the first line of a multiline string consis ts solely of the whitespace characters defined by the production {\em WHITESPACE } \ref{lexicalRules}), possibly prefixed by $\backslash$, then that line is ign ored, including the new line at its end.
2746 2746
2747 2747
2748 \rationale{ 2748 \rationale{
2749 The idea is to ignore whitespace, where whitespace is defined as tabs, spaces a nd newlines. These can be represented directly, but since for most characters pr efixing by backslash is an identity, we allow those forms as well. 2749 The idea is to ignore whitespace, where whitespace is defined as tabs, spaces a nd newlines. These can be represented directly, but since for most characters pr efixing by backslash is an identity, we allow those forms as well.
2750 } 2750 }
2751
2752 % could be clearer. Is the first line in """\t
2753 % """ ignored not. It depends if we mean whitespace before escapes are inter preted,
2754 % or after, or both. See https://code.google.com/p/dart/issues/detail?id=23020
2751 2755
2752 \LMHash{} 2756 \LMHash{}
2753 Strings support escape sequences for special characters. The escapes are: 2757 Strings support escape sequences for special characters. The escapes are:
2754 \begin{itemize} 2758 \begin{itemize}
2755 \item $\backslash$n for newline, equivalent to $\backslash$x0A. 2759 \item $\backslash$n for newline, equivalent to $\backslash$x0A.
2756 \item $\backslash$r for carriage return, equivalent to $\backslash$x0D. 2760 \item $\backslash$r for carriage return, equivalent to $\backslash$x0D.
2757 \item $\backslash$f for form feed, equivalent to $\backslash$x0C. 2761 \item $\backslash$f for form feed, equivalent to $\backslash$x0C.
2758 \item $\backslash$b for backspace, equivalent to $\backslash$x08. 2762 \item $\backslash$b for backspace, equivalent to $\backslash$x08.
2759 \item $\backslash$t for tab, equivalent to $\backslash$x09. 2763 \item $\backslash$t for tab, equivalent to $\backslash$x09.
2760 \item $\backslash$v for vertical tab, equivalent to $\backslash$x0B 2764 \item $\backslash$v for vertical tab, equivalent to $\backslash$x0B
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3909 3913
3910 \LMHash{} 3914 \LMHash{}
3911 A super method invocation $i$ has the form 3915 A super method invocation $i$ has the form
3912 3916
3913 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3917 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3914 3918
3915 \LMHash{} 3919 \LMHash{}
3916 Evaluation of $i$ proceeds as follows: 3920 Evaluation of $i$ proceeds as follows:
3917 3921
3918 \LMHash{} 3922 \LMHash{}
3919 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k }$. Let $S$ be the superclass of the immediately enclosing class, and let $f$ be the result of looking up method (\ref{ordinaryInvocation}) $m$ in $S$ with re spect to the current library $L$. 3923 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k }$. Let $S$ be the superclass of the immediately enclosing class, and let $f$ be the result of looking up method (\ref{methodLookup}) $m$ in $S$ with respect to the current library $L$.
3920 Let $p_1 \ldots p_h$ be the required parameters of $f$, let $p_1 \ldots p_m$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+l}$ be the opti onal parameters declared by $f$. 3924 Let $p_1 \ldots p_h$ be the required parameters of $f$, let $p_1 \ldots p_m$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+l}$ be the opti onal parameters declared by $f$.
3921 3925
3922 \LMHash{} 3926 \LMHash{}
3923 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. Otherwise method looku p has succeeded. 3927 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. Otherwise method looku p has succeeded.
3924 3928
3925 \LMHash{} 3929 \LMHash{}
3926 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 the current value of \THIS{}. The value of $i$ is the value returned after $f$ is executed. 3930 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 the current value of \THIS{}. The value of $i$ is the value returned after $f$ is executed.
3927 3931
3928 \LMHash{} 3932 \LMHash{}
3929 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $S$ with respect to $L$. If the getter loo kup succeeded, let $v_g$ be the value of the getter invocation $\SUPER{}.m$. The n the value of $i$ is the result of invoking 3933 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $S$ with respect to $L$. If the getter loo kup succeeded, let $v_g$ be the value of the getter invocation $\SUPER{}.m$. The n the value of $i$ is the result of invoking
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3983 3987
3984 3988
3985 \commentary{Closures derived from members via closurization are colloquially kno wn as tear-offs} 3989 \commentary{Closures derived from members via closurization are colloquially kno wn as tear-offs}
3986 3990
3987 Property extraction can be either {\em conditional} or {\em unconditional}. 3991 Property extraction can be either {\em conditional} or {\em unconditional}.
3988 3992
3989 \rationale { 3993 \rationale {
3990 Tear-offs using the \cd{ x\#id} syntax cannot be conditional at this time; this is inconsistent, and is likely to be addressed in the near future, perhaps via notation such as \cd{ x?\#id} . As indicated in section \ref{ecmaConformance}, experimentation in this area is allowed. 3994 Tear-offs using the \cd{ x\#id} syntax cannot be conditional at this time; this is inconsistent, and is likely to be addressed in the near future, perhaps via notation such as \cd{ x?\#id} . As indicated in section \ref{ecmaConformance}, experimentation in this area is allowed.
3991 } 3995 }
3992 3996
3993 Evaluation of a {\em conditional property extraction expression} $e$ of the form $e_1?.id$ is equivalent to the evaluation of the expression $((x) => x == \NU LL ? \NULL : x.id)(e_1)$. The static type of $e$ is the same as the static type of $e_1.id$. Let $T$ be the static type of $e_1$ and let $y$ be a fresh variable o type $T$. Exactly the same static warnings that would be caused by $y.id$ are also generated in the case of $e_1?.id$. 3997 Evaluation of a {\em conditional property extraction expression} $e$ of the form $e_1?.id$ is equivalent to the evaluation of the expression $((x) => x == \NU LL ? \NULL : x.id)(e_1)$. The static type of $e$ is the same as the static type of $e_1.id$. Let $T$ be the static type of $e_1$ and let $y$ be a fresh variable of type $T$. Exactly the same static warnings that would be caused by $y.id$ ar e also generated in the case of $e_1?.id$.
3994 3998
3995 \commentary{ 3999 \commentary{
3996 One might be tempted to conclude that for $e \ne \NULL{}$, $e?.v$ is always equi valent to $e.v$. However this is not the case. If $e$ is a type literal represen ting a type with static member $v$, then $e.v$ refers to that member, but $e?.v$ does not. 4000 One might be tempted to conclude that for $e \ne \NULL{}$, $e?.v$ is always equi valent to $e.v$. However this is not the case. If $e$ is a type literal represen ting a type with static member $v$, then $e.v$ refers to that member, but $e?.v$ does not.
3997 } 4001 }
3998 4002
3999 \LMHash{} 4003 \LMHash{}
4000 Unconditional property extraction takes several syntactic forms: $e.m$ (\ref{get terAccessAndMethodExtraction}), $\SUPER.m$ (\ref{superGetterAccessAndMethodClosu rization}), $e\#m$ (\ref{generalClosurization}), $\NEW{}$ $T\#m$ (\ref{namedCons tructorExtraction}), $\NEW{}$ $T\#$ (\ref{anonymousConstructorExtraction}) and $ \SUPER\#m$ (\ref{generalSuperPropertyExtraction}), where $e$ is an expression, $ m$ is an identifier optionally followed by an equal sign and $T$ is a type. 4004 Unconditional property extraction takes several syntactic forms: $e.m$ (\ref{get terAccessAndMethodExtraction}), $\SUPER.m$ (\ref{superGetterAccessAndMethodClosu rization}), $e\#m$ (\ref{generalClosurization}), $\NEW{}$ $T\#m$ (\ref{namedCons tructorExtraction}), $\NEW{}$ $T\#$ (\ref{anonymousConstructorExtraction}) and $ \SUPER\#m$ (\ref{generalSuperPropertyExtraction}), where $e$ is an expression, $ m$ is an identifier optionally followed by an equal sign and $T$ is a type.
4001 4005
4002 \subsubsection{Getter Access and Method Extraction} 4006 \subsubsection{Getter Access and Method Extraction}
4003 \LMLabel{getterAccessAndMethodExtraction} 4007 \LMLabel{getterAccessAndMethodExtraction}
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4148 \LMHash{} 4152 \LMHash{}
4149 It is a compile-time error if $e$ is a prefix object (\ref{imports}) and $m$ ref ers to a type or a member of class \cd{Object}. 4153 It is a compile-time error if $e$ is a prefix object (\ref{imports}) and $m$ ref ers to a type or a member of class \cd{Object}.
4150 4154
4151 \commentary{ 4155 \commentary{
4152 This restriction is in line with other limitations on the use of prefixes as obj ects. The only permitted uses of $p\#m$ are closurizing top level methods and ge tters imported via the prefix $p$. Top level methods are directly available by t heir qualified names: $p.m$. However, getters and setters are not, and allowing their closurization is the whole point of the $e\#m$ syntax. 4156 This restriction is in line with other limitations on the use of prefixes as obj ects. The only permitted uses of $p\#m$ are closurizing top level methods and ge tters imported via the prefix $p$. Top level methods are directly available by t heir qualified names: $p.m$. However, getters and setters are not, and allowing their closurization is the whole point of the $e\#m$ syntax.
4153 } 4157 }
4154 4158
4155 \LMHash{} 4159 \LMHash{}
4156 Let $T$ be the static type of $e$. It is a static type warning if $T$ does not h ave an accessible instance method or getter named $m$ unless either: 4160 Let $T$ be the static type of $e$. It is a static type warning if $T$ does not h ave an accessible instance method or getter named $m$ unless either:
4157 \begin{itemize} 4161 \begin{itemize}
4158 \item $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant proxy defined in \cd{dart:core}. Or 4162 \item $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \cd{dart:core}. Or
4159 \item $T$ is \cd{Type}, $e$ is a constant type literal and the class correspondi ng to $e$ declares an accessible static method or getter named $m$. 4163 \item $T$ is \cd{Type}, $e$ is a constant type literal and the class correspondi ng to $e$ declares an accessible static method or getter named $m$.
4160 \end{itemize} 4164 \end{itemize}
4161 4165
4162 The static type of $i$ is: 4166 The static type of $i$ is:
4163 \begin{itemize} 4167 \begin{itemize}
4164 \item The static type of function $T.m$, if $T$ has an accessible instance membe r named $m$. 4168 \item The static type of function $T.m$, if $T$ has an accessible instance membe r named $m$.
4165 \item The static type of function $T.m$, if $T$ is \cd{Type}, $e$ is a constant type literal and the class corresponding to $e$ declares an accessible static me mber or constructor named $m$. 4169 \item The static type of function $T.m$, if $T$ is \cd{Type}, $e$ is a constant type literal and the class corresponding to $e$ declares an accessible static me mber or constructor named $m$.
4166 \item The type \DYNAMIC{} otherwise. 4170 \item The type \DYNAMIC{} otherwise.
4167 \end{itemize} 4171 \end{itemize}
4168 4172
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
4391 \LMHash{} 4395 \LMHash{}
4392 Evaluation of an assignment $a$ of the form $v$ \code{=} $e$ proceeds as follows : 4396 Evaluation of an assignment $a$ of the form $v$ \code{=} $e$ proceeds as follows :
4393 4397
4394 4398
4395 %If there is neither a local variable declaration with name $v$ nor a setter dec laration with name $v=$ in the lexical scope enclosing $a$, then: 4399 %If there is neither a local variable declaration with name $v$ nor a setter dec laration with name $v=$ in the lexical scope enclosing $a$, then:
4396 %\begin{itemize} 4400 %\begin{itemize}
4397 % \item If $a$ occurs inside a top level or static function (be it function, me thod, getter, or setter) or variable initializer, evaluation of $a$ causes $e$ to be evaluated, after which a \code{NoSuchMethodError} is thrown. 4401 % \item If $a$ occurs inside a top level or static function (be it function, me thod, getter, or setter) or variable initializer, evaluation of $a$ causes $e$ to be evaluated, after which a \code{NoSuchMethodError} is thrown.
4398 % \item Otherwise, the assignment is equivalent to the assignment \code{ \THIS{} .$v$ = $e$}. 4402 % \item Otherwise, the assignment is equivalent to the assignment \code{ \THIS{} .$v$ = $e$}.
4399 % \end{itemize} 4403 % \end{itemize}
4400 4404
4401 %Otherwise, 4405 %Otherwise
4402 4406
4403 \LMHash{} 4407 \LMHash{}
4404 Let $d$ be the innermost declaration whose name is $v$ or $v=$, if it exists. 4408 Let $d$ be the innermost declaration whose name is $v$ or $v=$, if it exists.
4405 4409
4406 \LMHash{} 4410 \LMHash{}
4407 If $d$ is the declaration of a local variable, the expression $e$ is evaluated t o an object $o$. Then, the variable $v$ is bound to $o$ unless $v$ is \FINAL{} o r \CONST{}, in which case a dynamic error occurs. 4411 If $d$ is the declaration of a local variable, the expression $e$ is evaluated t o an object $o$. Then, the variable $v$ is bound to $o$ unless $v$ is \FINAL{} o r \CONST{}, in which case a dynamic error occurs.
4408 If no error occurs, the value of the assignment expression is $o$. 4412 If no error occurs, the value of the assignment expression is $o$.
4409 4413
4414 % add local functions per bug 23218
4415
4410 \LMHash{} 4416 \LMHash{}
4411 If $d$ is the declaration of a library variable, top level getter or top level s etter, the expression $e$ is evaluated to an object $o$. Then the setter $v=$ is invoked with its formal parameter bound to $o$. The value of the assignment exp ression is $o$. 4417 If $d$ is the declaration of a library variable, top level getter or top level s etter, the expression $e$ is evaluated to an object $o$. Then the setter $v=$ is invoked with its formal parameter bound to $o$. The value of the assignment exp ression is $o$.
4412 4418
4413 \LMHash{} 4419 \LMHash{}
4414 Otherwise, if $d$ is the declaration of a static variable, static getter or stat ic setter in class $C$, then the assignment is equivalent to the assignment \cod e{$C.v$ = $e$}. 4420 Otherwise, if $d$ is the declaration of a static variable, static getter or stat ic setter in class $C$, then the assignment is equivalent to the assignment \cod e{$C.v$ = $e$}.
4415 4421
4416 \LMHash{} 4422 \LMHash{}
4417 Otherwise, If $a$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $a$ causes $ e$ to be evaluated, after which a \code{NoSuchMethodError} is thrown. 4423 Otherwise, If $a$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $a$ causes $ e$ to be evaluated, after which a \code{NoSuchMethodError} is thrown.
4418 4424
4419 \LMHash{} 4425 \LMHash{}
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4528 4534
4529 \LMHash{} 4535 \LMHash{}
4530 It is a compile-time error to invoke any of the setters of class \cd{Object} on a prefix object (\ref{imports}) or on a constant type literal that is immediate ly followed by the token `.'. 4536 It is a compile-time error to invoke any of the setters of class \cd{Object} on a prefix object (\ref{imports}) or on a constant type literal that is immediate ly followed by the token `.'.
4531 4537
4532 4538
4533 4539
4534 \subsubsection{Compound Assignment} 4540 \subsubsection{Compound Assignment}
4535 \LMLabel{compoundAssignment} 4541 \LMLabel{compoundAssignment}
4536 4542
4537 \LMHash{} 4543 \LMHash{}
4538 Evaluation of a compound assignment of the form $v$ {\em ??=} $e$ is equivalent to the evaluation of the expression $((x) => x == \NULL{}$ ? $v=e : x)(v)$ whe re $x$ is a fresh variable that is not used in $e$. Evaluation of a compound ass ignment of the form $C.v$ {\em ??=} $e$, where $C$ is a type literal, is equival ent to the evaluation of the expression $((x) => x == \NULL{}$? $C.v=e: x)(C.v )$ where $x$ is a fresh variable that is not used in $e$. Evaluation of a compou nd assignment of the form $e_1.v$ {\em ??=} $e_2$ is equivalent to the evaluatio n of the expression $((x) =>((y) => y == \NULL{}$ ? $ x.v = e_2: y)(x.v))(e_1)$ where $x$ and $y$ are distinct fresh variables that are not used in $e_2$. Eval uation of a compound assignment of the form $e_1[e_2]$ {\em ??=} $e_3$ is equi valent to the evaluation of the expression 4544 Evaluation of a compound assignment of the form $v$ {\em ??=} $e$ is equivalent to the evaluation of the expression $((x) => x == \NULL{}$ ? $v=e : x)(v)$ whe re $x$ is a fresh variable that is not used in $e$. Evaluation of a compound ass ignment of the form $C.v$ {\em ??=} $e$, where $C$ is a type literal, is equival ent to the evaluation of the expression $((x) => x == \NULL{}$? $C.v=e: x)(C.v )$ where $x$ is a fresh variable that is not used in $e$.
4545
4546 \commentary {
4547 The two rules above also apply when the variable v or the type C is prefixed.
4548 }
4549
4550 Evaluation of a compound assignment of the form $e_1.v$ {\em ??=} $e_2$ is equiv alent to the evaluation of the expression $((x) =>((y) => y == \NULL{}$ ? $ x.v = e_2: y)(x.v))(e_1)$ where $x$ and $y$ are distinct fresh variables that are n ot used in $e_2$. Evaluation of a compound assignment of the form $e_1[e_2]$ { \em ??=} $e_3$ is equivalent to the evaluation of the expression
4539 $((a, i) => ((x) => x == \NULL{}$ ? $a[i] = e_3: x)(a[i]))(e_1, e_2)$ where $x$ , $a$ and $i$ are distinct fresh variables that are not used in $e_3$. Evaluatio n of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is equivalent t o the evaluation of the expression $((x) => x == \NULL{}$ ? $\SUPER.v = e: x)(\ SUPER.v)$ where $x$ is a fresh variable that is not used in $e$. 4551 $((a, i) => ((x) => x == \NULL{}$ ? $a[i] = e_3: x)(a[i]))(e_1, e_2)$ where $x$ , $a$ and $i$ are distinct fresh variables that are not used in $e_3$. Evaluatio n of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is equivalent t o the evaluation of the expression $((x) => x == \NULL{}$ ? $\SUPER.v = e: x)(\ SUPER.v)$ where $x$ is a fresh variable that is not used in $e$.
4540 4552
4541 \LMHash{} 4553 \LMHash{}
4542 Evaluation of a compound assignment of the form $e_1?.v$ {\em ??=} $e_2$ is equ ivalent to the evaluation of the expression \code{((x) $=>$ x == \NULL{} ? \NUL L: $x.v ??= e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. 4554 Evaluation of a compound assignment of the form $e_1?.v$ {\em ??=} $e_2$ is equ ivalent to the evaluation of the expression \code{((x) $=>$ x == \NULL{} ? \NUL L: $x.v ??= e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$.
4543 4555
4544 4556
4545 \LMHash{} 4557 \LMHash{}
4546 The static type of a compound assignment of the form $v$ {\em ??=} $e$ is the le ast upper bound of the static type of $v$ and the static type of $e$. Exactly t he same static warnings that would be caused by $v = e$ are also generated in th e case of $v$ {\em ??=} $e$. 4558 The static type of a compound assignment of the form $v$ {\em ??=} $e$ is the le ast upper bound of the static type of $v$ and the static type of $e$. Exactly t he same static warnings that would be caused by $v = e$ are also generated in th e case of $v$ {\em ??=} $e$.
4547 4559
4548 4560
4549 \LMHash{} 4561 \LMHash{}
4550 The static type of a compound assignment of the form $C.v$ {\em ??=} $e$ is th e least upper bound of the static type of $C.v$ and the static type of $e$. Exa ctly the same static warnings that would be caused by $C.v = e$ are also generat ed in the case of $C.v$ {\em ??=} $e$. 4562 The static type of a compound assignment of the form $C.v$ {\em ??=} $e$ is th e least upper bound of the static type of $C.v$ and the static type of $e$. Exa ctly the same static warnings that would be caused by $C.v = e$ are also generat ed in the case of $C.v$ {\em ??=} $e$.
4551 4563
4552 \LMHash{} 4564 \LMHash{}
4553 The static type of a compound assignment of the form $e_1.v$ {\em ??=} $e_2$ is the least upper bound of the static type of $e_1.v$ and the static type of $e_2 $. Let $T$ be the static type of $e_1$ and let $z$ be a fresh variable of type $ T$. Exactly the same static warnings that would be caused by $z.v = e$ are also generated in the case of $e_1.v$ {\em ??=} $e_2$. 4565 The static type of a compound assignment of the form $e_1.v$ {\em ??=} $e_2$ is the least upper bound of the static type of $e_1.v$ and the static type of $e_2 $. Let $T$ be the static type of $e_1$ and let $z$ be a fresh variable of type $ T$. Exactly the same static warnings that would be caused by $z.v = e_2$ are als o generated in the case of $e_1.v$ {\em ??=} $e_2$.
4554 4566
4555 \LMHash{} 4567 \LMHash{}
4556 The static type of a compound assignment of the form $e_1[e_2]$ {\em ??=} $e_3$ is the least upper bound of the static type of $e_1[e_2]$ and the static type of $e_3$. Exactly the same static warnings that would be caused by $e_1[e_2] = e _3$ are also generated in the case of $e_1[e_2]$ {\em ??=} $e_3$. 4568 The static type of a compound assignment of the form $e_1[e_2]$ {\em ??=} $e_3$ is the least upper bound of the static type of $e_1[e_2]$ and the static type of $e_3$. Exactly the same static warnings that would be caused by $e_1[e_2] = e _3$ are also generated in the case of $e_1[e_2]$ {\em ??=} $e_3$.
4557 4569
4558 \LMHash{} 4570 \LMHash{}
4559 The static type of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is the least upper bound of the static type of $\SUPER.v$ and the static type of $e$. Exactly the same static warnings that would be caused by $\SUPER.v = e$ ar e also generated in the case of $\SUPER.v$ {\em ??=} $e$. 4571 The static type of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is the least upper bound of the static type of $\SUPER.v$ and the static type of $e$. Exactly the same static warnings that would be caused by $\SUPER.v = e$ ar e also generated in the case of $\SUPER.v$ {\em ??=} $e$.
4560 4572
4561 \LMHash{} 4573 \LMHash{}
4562 For any other valid operator $op$, a compound assignment of the form $v$ $op\cod e{=} e$ is equivalent to $v \code{=} v$ $op$ $e$. A compound assignment of the f orm $C.v$ $op \code{=} e$ is equivalent to $C.v \code{=} C.v$ $op$ $e$. A compou nd assignment of the form $e_1.v$ $op = e_2$ is equivalent to \code{((x) $=>$ x. v = x.v $op$ $e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. A compound assignment of the form $e_1[e_2]$ $op\code{=} e_3$ is equivalent to 4574 For any other valid operator $op$, a compound assignment of the form $v$ $op\cod e{=} e$ is equivalent to $v \code{=} v$ $op$ $e$. A compound assignment of the f orm $C.v$ $op \code{=} e$ is equivalent to $C.v \code{=} C.v$ $op$ $e$. A compou nd assignment of the form $e_1.v$ $op = e_2$ is equivalent to \code{((x) $=>$ x. v = x.v $op$ $e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. A compound assignment of the form $e_1[e_2]$ $op\code{=} e_3$ is equivalent to
4563 \code{((a, i) $=>$ a[i] = a[i] $op$ $e_3$)($e_1, e_2$)} where $a$ and $i$ are a variables that are not used in $e_3$. 4575 \code{((a, i) $=>$ a[i] = a[i] $op$ $e_3$)($e_1, e_2$)} where $a$ and $i$ are a variables that are not used in $e_3$.
4564 4576
4565 \LMHash{} 4577 \LMHash{}
4566 Evaluation of a compound assignment of the form $e_1?.v$ $op = e_2$ is equivalen t to \code{((x) $=>$ x?.v = x.v $op$ $e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. The static type of $e_1?.v$ $op = e_2$ is the static type of $e_1.v$ $op$ $e_2$. Exactly the same static warnings that would be caused by $e_1.v$ $op = e_2$ are also generated in the case of $e_1?.v$ $op = e_2$. 4578 Evaluation of a compound assignment of the form $e_1?.v$ $op = e_2$ is equivalen t to \code{((x) $=>$ x?.v = x.v $op$ $e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. The static type of $e_1?.v$ $op = e_2$ is the static type of $e_1.v$ $op$ $e_2$. Exactly the same static warnings that would be caused by $e_1.v$ $op = e_2$ are also generated in the case of $e_1?.v$ $op = e_2$.
4567 4579
4580 % Buggy. Allows C?.v = e.
4581
4568 \begin{grammar} 4582 \begin{grammar}
4569 {\bf compoundAssignmentOperator:}`*='; 4583 {\bf compoundAssignmentOperator:}`*=';
4570 `/='; 4584 `/=';
4571 `\~{}/='; 4585 `\~{}/=';
4572 `\%='; 4586 `\%=';
4573 `+='; 4587 `+=';
4574 `-='; 4588 `-=';
4575 `{\escapegrammar \lt \lt}='; 4589 `{\escapegrammar \lt \lt}=';
4576 `{\escapegrammar \gt \gt}='; 4590 `{\escapegrammar \gt \gt}=';
4577 `\&='; 4591 `\&=';
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
4995 \end{grammar} 5009 \end{grammar}
4996 5010
4997 \LMHash{} 5011 \LMHash{}
4998 A {\em postfix expression} is either a primary expression, a function, method o r getter invocation, or an invocation of a postfix operator on an expression $e$ . 5012 A {\em postfix expression} is either a primary expression, a function, method o r getter invocation, or an invocation of a postfix operator on an expression $e$ .
4999 5013
5000 \LMHash{} 5014 \LMHash{}
5001 A postfix expression of the form \code{$v$++}, where $v$ is an identifier, is eq uivalent to \code{()\{var r = $v$; $v$ = r + 1; return r\}()}. 5015 A postfix expression of the form \code{$v$++}, where $v$ is an identifier, is eq uivalent to \code{()\{var r = $v$; $v$ = r + 1; return r\}()}.
5002 5016
5003 \rationale{The above ensures that if $v$ is a field, the getter gets called exac tly once. Likewise in the cases below. 5017 \rationale{The above ensures that if $v$ is a field, the getter gets called exac tly once. Likewise in the cases below.
5004 } 5018 }
5019 %what about e?.x++
5005 5020
5006 \LMHash{} 5021 \LMHash{}
5007 A postfix expression of the form \code{$C.v$ ++} is equivalent to 5022 A postfix expression of the form \code{$C.v$ ++} is equivalent to
5008 5023
5009 \code{()\{var r = $C.v$; $C.v$ = r + 1; return r\}()}. 5024 \code{()\{var r = $C.v$; $C.v$ = r + 1; return r\}()}.
5010 5025
5011 \LMHash{} 5026 \LMHash{}
5012 A postfix expression of the form \code{$e_1.v$++} is equivalent to 5027 A postfix expression of the form \code{$e_1.v$++} is equivalent to
5013 5028
5014 \code{(x)\{var r = x.v; x.v = r + 1; \RETURN{} r\}($e_1$)}. 5029 \code{(x)\{var r = x.v; x.v = r + 1; \RETURN{} r\}($e_1$)}.
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
5618 \WHILE{} (n0.moveNext()) \{ 5633 \WHILE{} (n0.moveNext()) \{
5619 $finalConstVarOrType?$ id = n0.current; 5634 $finalConstVarOrType?$ id = n0.current;
5620 $s$ 5635 $s$
5621 \} 5636 \}
5622 \end{dartCode} 5637 \end{dartCode}
5623 where \code{n0} is an identifier that does not occur anywhere in the program. 5638 where \code{n0} is an identifier that does not occur anywhere in the program.
5624 5639
5625 \commentary{ 5640 \commentary{
5626 Note that in fact, using a \CONST{} variable would give rise to a compile time error since \cd{n0.current} is not a constant expression. 5641 Note that in fact, using a \CONST{} variable would give rise to a compile time error since \cd{n0.current} is not a constant expression.
5627 } 5642 }
5643
5644 It is a static warning if the static type of $e$ does not have a member \cd{iter ator}. It is a static warning if the static type of \cd{$e$.iterator} does not h ave a method \cd{moveNext}. It is a static warning if static return type of \cd {$e$.iterator.moveNext()} is not assignable to the static type of \cd{id}.
Paul Berry 2015/06/12 18:28:09 I don't think this is what we want: 1. It seems r
5645
5646
5647 \commentary {
5648 One might have required that \cd{n0} had type \cd{Iterable$<T>$} where $T$ was t he static type of \cd{id}. However, that would cause failure in checked mode if $e$ was merely emulating the \cd{Iterable} interface.
5649 }
5650
5628 5651
5629 \subsubsection{Asynchronous For-in} 5652 \subsubsection{Asynchronous For-in}
5630 \LMLabel{asynchronousFor-in} 5653 \LMLabel{asynchronousFor-in}
5631 5654
5632 \LMHash{} 5655 \LMHash{}
5633 A for-in statement may be asynchronous. The asynchronous form is designed to ite rate over streams. An asynchronous for loop is distinguished by the keyword \AWA IT{} immediately preceding the keyword \FOR. 5656 A for-in statement may be asynchronous. The asynchronous form is designed to ite rate over streams. An asynchronous for loop is distinguished by the keyword \AWA IT{} immediately preceding the keyword \FOR.
5634 5657
5635 \LMHash{} 5658 \LMHash{}
5636 Execution of a for-in statement of the form \code{\AWAIT{} \FOR{} (finalConstVa rOrType? id \IN{} $e$) $s$} proceeds as follows: 5659 Execution of a for-in statement of the form \code{\AWAIT{} \FOR{} (finalConstVa rOrType? id \IN{} $e$) $s$} proceeds as follows:
5637 5660
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
6550 \LMHash{} 6573 \LMHash{}
6551 An immediate import directive $I$ may optionally include a prefix clause of the form \AS{} \code{Id} used to prefix names imported by $I$. A deferred import mus t include a prefix clause or a compile time error occurs. It is a compile-time e rror if a prefix used in a deferred import is used in another import clause. 6574 An immediate import directive $I$ may optionally include a prefix clause of the form \AS{} \code{Id} used to prefix names imported by $I$. A deferred import mus t include a prefix clause or a compile time error occurs. It is a compile-time e rror if a prefix used in a deferred import is used in another import clause.
6552 6575
6553 \LMHash{} 6576 \LMHash{}
6554 An import directive $I$ may optionally include a namespace combinator clauses us ed to restrict the set of names imported by $I$. Currently, two namespace combin ators are supported: \HIDE{} and \SHOW{}. 6577 An import directive $I$ may optionally include a namespace combinator clauses us ed to restrict the set of names imported by $I$. Currently, two namespace combin ators are supported: \HIDE{} and \SHOW{}.
6555 6578
6556 \LMHash{} 6579 \LMHash{}
6557 Let $I$ be an import directive that refers to a URI via the string $s_1$. Evalua tion of $I$ proceeds as follows: 6580 Let $I$ be an import directive that refers to a URI via the string $s_1$. Evalua tion of $I$ proceeds as follows:
6558 6581
6559 \LMHash{} 6582 \LMHash{}
6560 If $I$ is a deferred import, no evaluation takes place. Instead, a mapping of th e name of the prefix, $p$ to a {\em deferred prefix object} is added to the scop e of $L$. 6583 If $I$ is a deferred import, no evaluation takes place. Instead, a mapping of th e name of the prefix, $p$ to a {\em deferred prefix object} is added to the scop e of the current library $L$.
6561 The deferred prefix object has the following methods: 6584 The deferred prefix object has the following methods:
6562 6585
6563 \begin{itemize} 6586 \begin{itemize}
6564 \item \code{loadLibrary}. This method returns a future $f$. When called, the met hod causes an immediate import $I'$ to be executed at some future time, where $I '$ is is derived from $I$ by eliding the word \DEFERRED{} and adding a \HIDE{} \ code{loadLibrary} combinator clause. When $I'$ executes without error, $f$ comp letes successfully. If $I'$ executes without error, we say that the call to \cod e{loadLibrary} has succeeded, otherwise we say the call has failed. 6587 \item \code{loadLibrary}. This method returns a future $f$. When called, the met hod causes an immediate import $I'$ to be executed at some future time, where $I '$ is is derived from $I$ by eliding the word \DEFERRED{} and adding a \HIDE{} \ code{loadLibrary} combinator clause. When $I'$ executes without error, $f$ comp letes successfully. If $I'$ executes without error, we say that the call to \cod e{loadLibrary} has succeeded, otherwise we say the call has failed.
6565 \item For every top level function $f$ named $id$ in $L$, a corresponding metho d named $id$ with the same signature as $f$. Calling the method results in a run time error. 6588 \item For every top level function $f$ named $id$ in the imported library $B$, a corresponding method named $id$ with the same signature as $f$. Calling the me thod results in a runtime error.
6566 \item For every top level getter $g$ named $id$ in $L$, a corresponding getter n amed $id$ with the same signature as $g$. Calling the method results in a runti me error. 6589 \item For every top level getter $g$ named $id$ in $B$, a corresponding getter n amed $id$ with the same signature as $g$. Calling the method results in a runti me error.
6567 \item For every top level setter $s$ named $id$ in $L$, a corresponding setter n amed $id$ with the same signature as $s$. Calling the method results in a runti me error. 6590 \item For every top level setter $s$ named $id$ in $B$, a corresponding setter n amed $id$ with the same signature as $s$. Calling the method results in a runti me error.
6568 \item For every type $T$ named $id$ in $L$, a corresponding getter named $id$ wi th return type \code{Type}. Calling the method results in a runtime error. 6591 \item For every type $T$ named $id$ in $B$, a corresponding getter named $id$ wi th return type \code{Type}. Calling the method results in a runtime error.
6569 \end{itemize} 6592 \end{itemize}
6570 6593
6594 \rationale {
6595 The purpose of adding members of $B$ to $p$ is to ensure that any warnings issu ed when using $p$ are correct, and no spurious warnings are generated. In fact, at runtime we cannot add these members until $B$ is loaded; but any such invoca tions will fail at runtime as specified by virtue of being completely absent.
6596 }
6597 %But this is still a lie detectable by reflection. Probably revise so the type o f p has these members but p does not.
6598
6571 \LMHash{} 6599 \LMHash{}
6572 After a call succeeds, the name $p$ is mapped to a non-deferred prefix object as described below. In addition, the prefix object also supports the \code{loadLib rary} method, and so it is possible to call \code{loadLibrary} again. If a call fails, nothing happens, and one again has the option to call \code{loadLibrary} again. Whether a repeated call to \code{loadLibrary} succeeds will vary as descr ibed below. 6600 After a call succeeds, the name $p$ is mapped to a non-deferred prefix object as described below. In addition, the prefix object also supports the \code{loadLib rary} method, and so it is possible to call \code{loadLibrary} again. If a call fails, nothing happens, and one again has the option to call \code{loadLibrary} again. Whether a repeated call to \code{loadLibrary} succeeds will vary as descr ibed below.
6573 6601
6574 \LMHash{} 6602 \LMHash{}
6575 The effect of a repeated call to \code{$p$.loadLibrary} is as follows: 6603 The effect of a repeated call to \code{$p$.loadLibrary} is as follows:
6576 \begin{itemize} 6604 \begin{itemize}
6577 \item 6605 \item
6578 If another call to \code{$p$.loadLibrary} has already succeeded, the repeated ca ll also succeeds. 6606 If another call to \code{$p$.loadLibrary} has already succeeded, the repeated ca ll also succeeds.
6579 Otherwise, 6607 Otherwise,
6580 \item 6608 \item
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
7263 % ensure that Object and dynamic may be assign dot a function type 7291 % ensure that Object and dynamic may be assign dot a function type
7264 A function is always an instance of some class that implements the class \code{F unction} and implements a \CALL{} method with the same signature as the function . All function types are subtypes of \code{Function}. 7292 A function is always an instance of some class that implements the class \code{F unction} and implements a \CALL{} method with the same signature as the function . All function types are subtypes of \code{Function}.
7265 If a type $I$ includes an instance method named \CALL{}, and the type of \CALL{} is the function type $F$, then $I$ is considered to be more specific than $F$. It is a static warning if a concrete class implements \cd{Function} and does no t have a concrete method named \CALL{} unless that class has an implementation o f \cd{noSuchMethod()} distinct from the one declared in class \cd{Object}. 7293 If a type $I$ includes an instance method named \CALL{}, and the type of \CALL{} is the function type $F$, then $I$ is considered to be more specific than $F$. It is a static warning if a concrete class implements \cd{Function} and does no t have a concrete method named \CALL{} unless that class has an implementation o f \cd{noSuchMethod()} distinct from the one declared in class \cd{Object}.
7266 7294
7267 7295
7268 7296
7269 7297
7270 %\commentary{Need to specify how a function values dynamic type is derived from its static signature.} 7298 %\commentary{Need to specify how a function values dynamic type is derived from its static signature.}
7271 7299
7272 \LMHash{} 7300 \LMHash{}
7273 A function type $(T_1, \ldots T_{k}, [T_{k+1} \ldots, T_{n+m}]) \rightarrow T$ is a more specific than the 7301 A function type $(T_1, \ldots T_{k}, [T_{k+1} \ldots, T_{n+m}]) \rightarrow T$ is more specific than the
7274 function type $(S_1, \ldots, S_{k+j}, [S_{k+j+1} \ldots, S_{n}]) \rightarrow S$, if all of the following conditions are met: 7302 function type $(S_1, \ldots, S_{k+j}, [S_{k+j+1} \ldots, S_{n}]) \rightarrow S$, if all of the following conditions are met:
7275 \begin{enumerate} 7303 \begin{enumerate}
7276 \item Either 7304 \item Either
7277 \begin{itemize} 7305 \begin{itemize}
7278 \item $S$ is \VOID{}, Or 7306 \item $S$ is \VOID{}, Or
7279 \item $T << S$. 7307 \item $T << S$.
7280 \end{itemize} 7308 \end{itemize}
7281 \item $\forall i \in 1 .. n, T_i << S_i$. 7309 \item $\forall i \in 1 .. n, T_i << S_i$.
7282 \end{enumerate} 7310 \end{enumerate}
7283 7311
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
7773 7801
7774 The invariant that each normative paragraph is associated with a line 7802 The invariant that each normative paragraph is associated with a line
7775 containing the text \LMHash{} should be maintained. Extra occurrences 7803 containing the text \LMHash{} should be maintained. Extra occurrences
7776 of \LMHash{} can be added if needed, e.g., in order to make 7804 of \LMHash{} can be added if needed, e.g., in order to make
7777 individual \item{}s in itemized lists addressable. Each \LM.. command 7805 individual \item{}s in itemized lists addressable. Each \LM.. command
7778 must occur on a separate line. \LMHash{} must occur immediately 7806 must occur on a separate line. \LMHash{} must occur immediately
7779 before the associated paragraph, and \LMLabel must occur immediately 7807 before the associated paragraph, and \LMLabel must occur immediately
7780 after the associated \section{}, \subsection{} etc. 7808 after the associated \section{}, \subsection{} etc.
7781 7809
7782 ---------------------------------------------------------------------- 7810 ----------------------------------------------------------------------
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