OLD | NEW |
1 \documentclass{article} | 1 \documentclass{article} |
2 \usepackage{epsfig} | 2 \usepackage{epsfig} |
3 \usepackage{dart} | 3 \usepackage{dart} |
4 \usepackage{bnf} | 4 \usepackage{bnf} |
5 \usepackage{hyperref} | 5 \usepackage{hyperref} |
6 \newcommand{\code}[1]{{\sf #1}} | 6 \newcommand{\code}[1]{{\sf #1}} |
7 \title{Dart Programming Language Specification \\ | 7 \title{Dart Programming Language Specification \\ |
8 {\large Version 1.3}} | 8 {\large Version 1.4}} |
9 %\author{The Dart Team} | 9 %\author{The Dart Team} |
10 \begin{document} | 10 \begin{document} |
11 \maketitle | 11 \maketitle |
12 \tableofcontents | 12 \tableofcontents |
13 | 13 |
14 | 14 |
15 \newpage | 15 \newpage |
16 | 16 |
17 \pagestyle{myheadings} | 17 \pagestyle{myheadings} |
18 \markright{Dart Programming Language Specification} | 18 \markright{Dart Programming Language Specification} |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 \label{generativeConstructors} | 1052 \label{generativeConstructors} |
1053 | 1053 |
1054 A {\em generative constructor} consists of a constructor name, a constructor par
ameter list, and either a redirect clause or an initializer list and an optiona
l body. | 1054 A {\em generative constructor} consists of a constructor name, a constructor par
ameter list, and either a redirect clause or an initializer list and an optiona
l body. |
1055 | 1055 |
1056 \begin{grammar} | 1056 \begin{grammar} |
1057 {\bf constructorSignature:} | 1057 {\bf constructorSignature:} |
1058 identifier (`{\escapegrammar .}' identifier)? formalParameterList | 1058 identifier (`{\escapegrammar .}' identifier)? formalParameterList |
1059 . | 1059 . |
1060 \end{grammar} | 1060 \end{grammar} |
1061 | 1061 |
1062 A {\em constructor parameter list} is a parenthesized, comma-separated list of f
ormal constructor parameters. A {\em formal constructor parameter} is either a f
ormal parameter (\ref{formalParameters}) or an initializing formal. An {\em init
ializing formal} has the form \code{\THIS{}.id}, where \code{id} is the name of
an instance variable of the immediately enclosing class. It is a compile-time er
ror if an initializing formal is used by a function other than a non-redirecting
generative constructor. | 1062 A {\em constructor parameter list} is a parenthesized, comma-separated list of f
ormal constructor parameters. A {\em formal constructor parameter} is either a f
ormal parameter (\ref{formalParameters}) or an initializing formal. An {\em init
ializing formal} has the form \code{\THIS{}.id}, where \code{id} is the name of
an instance variable of the immediately enclosing class. It is a compile-time e
rror if \code{id} is not an instance variable of the immediately enclosing class
. It is a compile-time error if an initializing formal is used by a function oth
er than a non-redirecting generative constructor. |
1063 | 1063 |
1064 If an explicit type is attached to the initializing formal, that is its static t
ype. Otherwise, the type of an initializing formal named \code{id} is $T_{id}$,
where $T_{id}$ is the type of the field named \code{id} in the immediately enclo
sing class. It is a static warning if the static type of \code{id} is not assign
able to $T_{id}$. | 1064 If an explicit type is attached to the initializing formal, that is its static t
ype. Otherwise, the type of an initializing formal named \code{id} is $T_{id}$,
where $T_{id}$ is the type of the field named \code{id} in the immediately enclo
sing class. It is a static warning if the static type of \code{id} is not assign
able to $T_{id}$. |
1065 | 1065 |
1066 Using an initializing formal \code{\THIS{}.id} in a formal parameter list does n
ot introduce a formal parameter name into the scope of the constructor. However,
the initializing formal does effect the type of the constructor function exactl
y as if a formal parameter named \code{id} of the same type were introduced in
the same position. | 1066 Using an initializing formal \code{\THIS{}.id} in a formal parameter list does n
ot introduce a formal parameter name into the scope of the constructor. However,
the initializing formal does effect the type of the constructor function exactl
y as if a formal parameter named \code{id} of the same type were introduced in
the same position. |
1067 | 1067 |
1068 Initializing formals are executed during the execution of generative constructor
s detailed below. Executing an initializing formal \code{\THIS{}.id} causes the
field \code{id} of the immediately surrounding class to be assigned the value o
f the corresponding actual parameter, unless $id$ is a final variable that has a
lready been initialized, in which case a runtime error occurs. | 1068 Initializing formals are executed during the execution of generative constructor
s detailed below. Executing an initializing formal \code{\THIS{}.id} causes the
field \code{id} of the immediately surrounding class to be assigned the value o
f the corresponding actual parameter, unless $id$ is a final variable that has a
lready been initialized, in which case a runtime error occurs. |
1069 | 1069 |
1070 | 1070 |
1071 \commentary{ | 1071 \commentary{ |
1072 The above rule allows initializing formals to be used as optional parameters: | 1072 The above rule allows initializing formals to be used as optional parameters: |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 Even where type parameters are in scope there are numerous restrictions at this
time: | 1907 Even where type parameters are in scope there are numerous restrictions at this
time: |
1908 \begin{itemize} | 1908 \begin{itemize} |
1909 \item A type parameter cannot be used to name a constructor in an instance creat
ion expression (\ref{instanceCreation}). | 1909 \item A type parameter cannot be used to name a constructor in an instance creat
ion expression (\ref{instanceCreation}). |
1910 \item A type parameter cannot be used as a superclass or superinterface (\ref{su
perclasses}, \ref{superinterfaces}, \ref{interfaceSuperinterfaces}). | 1910 \item A type parameter cannot be used as a superclass or superinterface (\ref{su
perclasses}, \ref{superinterfaces}, \ref{interfaceSuperinterfaces}). |
1911 \item A type parameter cannot be used as a generic type. | 1911 \item A type parameter cannot be used as a generic type. |
1912 \end{itemize} | 1912 \end{itemize} |
1913 | 1913 |
1914 The normative versions of these are given in the appropriate sections of this s
pecification. Some of these restrictions may be lifted in the future. | 1914 The normative versions of these are given in the appropriate sections of this s
pecification. Some of these restrictions may be lifted in the future. |
1915 } | 1915 } |
1916 | 1916 |
| 1917 %The {\em induced type set}, $S$, of a parameterized type $T$ is the set consist
ing of |
| 1918 %\begin{itemize} |
| 1919 %\item The supertypes of any type in $S$. |
| 1920 %\item The type arguments of any parameterized type in $S$. |
| 1921 %\end{itemize} |
1917 | 1922 |
| 1923 %Let $P$ be the instantiation of a generic type with its own type parameters. It
is a compile-time error if the induced type set of $P$ is not finite. |
| 1924 |
| 1925 %\rationale {A typical recursive type declaration such as} |
| 1926 |
| 1927 %\begin{dartCode} |
| 1928 %\CLASS{} B$<$S$>$ \{\} |
| 1929 %\CLASS{} D$<$T$>$ \EXTENDS{} B$<$D$<$T$>>$ \{\} |
| 1930 %\end{dartCode} |
| 1931 |
| 1932 %\rationale{ |
| 1933 %poses no problem under this rule. The instantiation \cd{D$<$T$>$} has an induce
d |
| 1934 %set consisting of: \cd{B$<$D$<$T$>>$, Object, D$<$T$>$, T}. However, the follow
ing variant |
| 1935 %} |
| 1936 |
| 1937 %\begin{dartCode} |
| 1938 %\CLASS{} B$<$S$>$ \{\} |
| 1939 %\CLASS{} D$<$T$>$ \EXTENDS{} B$<$D$<$D$<$T$>>>$ \{\} |
| 1940 %\end{dartCode} |
| 1941 |
| 1942 %\rationale{ |
| 1943 %is disallowed. Consider again the instantiation \cd{D$<$T$>$}. It leads to the |
| 1944 %superclass \cd{B$<$D$<$D$<$T$>>>$}, and so adds \cd{D$<$D$< $T$>>$} to the indu
ced set. The latter in turn leads to \cd{B$<$D$<$D$<$D$<$T$>>>>$} and \cd{D$<$D
$<$D$<$T$>>>$} |
| 1945 %and so on ad infinitum.} |
| 1946 |
| 1947 %\commentary{ |
| 1948 %The above requirement does not preclude the use of arbitrary recursive types in
the body of a generic class. } |
1918 %A generic has a type parameter scope. The enclosing scope of a type parameter s
cope of a generic G is the enclosing scope of G. | 1949 %A generic has a type parameter scope. The enclosing scope of a type parameter s
cope of a generic G is the enclosing scope of G. |
1919 | 1950 |
1920 | 1951 |
1921 %class T {...} | 1952 %class T {...} |
1922 | 1953 |
1923 %class G<T> extends T; | 1954 %class G<T> extends T; |
1924 | 1955 |
1925 %By current rules, this is illegal. Make sure we preserve this. | 1956 %By current rules, this is illegal. Make sure we preserve this. |
1926 | 1957 |
1927 | 1958 |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2566 % identifier `{\escapegrammar :}' expression; | 2597 % identifier `{\escapegrammar :}' expression; |
2567 expression `{\escapegrammar :}' expression | 2598 expression `{\escapegrammar :}' expression |
2568 . | 2599 . |
2569 \end{grammar} | 2600 \end{grammar} |
2570 | 2601 |
2571 A {\em map literal} consists of zero or more entries. Each entry has a {\em key}
and a {\em value}. Each key and each value is denoted by an expression. | 2602 A {\em map literal} consists of zero or more entries. Each entry has a {\em key}
and a {\em value}. Each key and each value is denoted by an expression. |
2572 | 2603 |
2573 If a map literal begins with the reserved word \CONST{}, it is a {\em constant m
ap literal} which is a compile-time constant (\ref{constants}) and therefore eva
luated at compile-time. Otherwise, it is a {\em run-time map literal} and it is
evaluated at run-time. Only run-time map literals can be mutated | 2604 If a map literal begins with the reserved word \CONST{}, it is a {\em constant m
ap literal} which is a compile-time constant (\ref{constants}) and therefore eva
luated at compile-time. Otherwise, it is a {\em run-time map literal} and it is
evaluated at run-time. Only run-time map literals can be mutated |
2574 after they are created. Attempting to mutate a constant map literal will result
in a dynamic error. | 2605 after they are created. Attempting to mutate a constant map literal will result
in a dynamic error. |
2575 | 2606 |
2576 It is a compile-time error if either a key or a value of an entry in a constant
map literal is not a compile-time constant. It is a compile-time error if the ke
y of an entry in a constant map literal is an instance of a class that implement
s the operator $==$ unless the key is a string or integer. It is a compile-time
error if the type arguments of a constant map literal include a type parameter. | 2607 It is a compile-time error if either a key or a value of an entry in a constant
map literal is not a compile-time constant. It is a compile-time error if the ke
y of an entry in a constant map literal is an instance of a class that implement
s the operator $==$ unless the key is a |
| 2608 %symbol, |
| 2609 string, an integer, literal symbol or the result of invoking a constant construc
tor of class \cd{Symbol}. It is a compile-time error if the type arguments of a
constant map literal include a type parameter. |
2577 | 2610 |
2578 The value of a constant map literal \CONST{}$ <K, V>\{k_1:e_1\ldots k_n :e_n\}$
is an object $m$ whose class implements the built-in class $Map<K, V>$. The ent
ries of $m$ are $u_i:v_i, i \in 1 .. n$, where $u_i$ is the value of the compile
-time expression $k_i$ and $v_i$ is the value of the compile-time expression $e_
i$. The value of a constant map literal \CONST{} $\{k_1:e_1\ldots k_n :e_n\}$
is defined as the value of a constant map literal \CONST{} $<\DYNAMIC{}, \DYNAMI
C{}>\{k_1:e_1\ldots k_n :e_n\}$. | 2611 The value of a constant map literal \CONST{}$ <K, V>\{k_1:e_1\ldots k_n :e_n\}$
is an object $m$ whose class implements the built-in class $Map<K, V>$. The ent
ries of $m$ are $u_i:v_i, i \in 1 .. n$, where $u_i$ is the value of the compile
-time expression $k_i$ and $v_i$ is the value of the compile-time expression $e_
i$. The value of a constant map literal \CONST{} $\{k_1:e_1\ldots k_n :e_n\}$
is defined as the value of a constant map literal \CONST{} $<\DYNAMIC{}, \DYNAMI
C{}>\{k_1:e_1\ldots k_n :e_n\}$. |
2579 | 2612 |
2580 Let $map_1 =$ \CONST{}$ <K, V>\{k_{11}:e_{11} \ldots k_{1n} :e_{1n}\}$ and $map
_2 =$ \CONST{}$ <J, U>\{k_{21}:e_{21} \ldots k_{2n} :e_{2n}\}$ be two constant
map literals. Let the keys of $map_1$ and $map_2$ evaluate to $s_{11} \ldots s
_{1n}$ and $s_{21} \ldots s_{2n}$ respectively, and let the elements of $map
_1$ and $map_2$ evaluate to $o_{11} \ldots o_{1n}$ and $o_{21} \ldots o_{2n}$
respectively. Iff \code{identical($o_{1i}$, $o_{2i}$)} and \code{identical($s_{
1i}$, $s_{2i}$)} for $i \in 1.. n$, and $K = J, V = U$ then \code{identical($map
_1$, $map_2$)}. | 2613 Let $map_1 =$ \CONST{}$ <K, V>\{k_{11}:e_{11} \ldots k_{1n} :e_{1n}\}$ and $map
_2 =$ \CONST{}$ <J, U>\{k_{21}:e_{21} \ldots k_{2n} :e_{2n}\}$ be two constant
map literals. Let the keys of $map_1$ and $map_2$ evaluate to $s_{11} \ldots s
_{1n}$ and $s_{21} \ldots s_{2n}$ respectively, and let the elements of $map
_1$ and $map_2$ evaluate to $o_{11} \ldots o_{1n}$ and $o_{21} \ldots o_{2n}$
respectively. Iff \code{identical($o_{1i}$, $o_{2i}$)} and \code{identical($s_{
1i}$, $s_{2i}$)} for $i \in 1.. n$, and $K = J, V = U$ then \code{identical($map
_1$, $map_2$)}. |
2581 | 2614 |
2582 \commentary{In other words, constant map literals are canonicalized.} | 2615 \commentary{In other words, constant map literals are canonicalized.} |
2583 | 2616 |
2584 A runtime map literal $<K, V>\{k_1:e_1\ldots k_n :e_n\}$ is evaluated as follow
s: | 2617 A runtime map literal $<K, V>\{k_1:e_1\ldots k_n :e_n\}$ is evaluated as follow
s: |
2585 \begin{itemize} | 2618 \begin{itemize} |
2586 \item | 2619 \item |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3106 | 3139 |
3107 Let $T_i$ be the static type of $a_i$, let $S_i$ be the type of $p_i, i \in 1 ..
h+k$ and let $S_q$ be the type of the named parameter $q$ of $f$. It is a stat
ic warning if $T_j$ may not be assigned to $S_j, j \in 1..m$. It is a static wa
rning if $m < h$ or if $m > n$. Furthermore, each $q_i, 1 \le i \le l$, must ha
ve a corresponding named parameter in the set $\{p_{n+1}, \ldots, p_{n +k}\}$ or
a static warning occurs. It is a static warning if $T_{m+j}$ may not be assign
ed to $S_{q_j}, j \in 1 .. l$. | 3140 Let $T_i$ be the static type of $a_i$, let $S_i$ be the type of $p_i, i \in 1 ..
h+k$ and let $S_q$ be the type of the named parameter $q$ of $f$. It is a stat
ic warning if $T_j$ may not be assigned to $S_j, j \in 1..m$. It is a static wa
rning if $m < h$ or if $m > n$. Furthermore, each $q_i, 1 \le i \le l$, must ha
ve a corresponding named parameter in the set $\{p_{n+1}, \ldots, p_{n +k}\}$ or
a static warning occurs. It is a static warning if $T_{m+j}$ may not be assign
ed to $S_{q_j}, j \in 1 .. l$. |
3108 | 3141 |
3109 \subsubsection{ Unqualified Invocation} | 3142 \subsubsection{ Unqualified Invocation} |
3110 \label{unqualifiedInvocation} | 3143 \label{unqualifiedInvocation} |
3111 | 3144 |
3112 An unqualified function invocation $i$ has the form | 3145 An unqualified function invocation $i$ has the form |
3113 | 3146 |
3114 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, | 3147 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, |
3115 | 3148 |
3116 where $id$ is an identifier. | 3149 where $id$ is an identifier or an identifier qualified with a library prefix. |
3117 | 3150 |
3118 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the
innermost such declaration. Then: | 3151 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the
innermost such declaration. Then: |
3119 \begin{itemize} | 3152 \begin{itemize} |
3120 \item | 3153 \item |
3121 If $f_{id}$ is a local function, a library function, a library or static getter
or a variable then $i$ is interpreted as a function expression invocation (\ref
{functionExpressionInvocation}). | 3154 If $f_{id}$ is a local function, a library function, a library or static getter
or a variable then $i$ is interpreted as a function expression invocation (\ref
{functionExpressionInvocation}). |
3122 \item | 3155 \item |
3123 Otherwise, if $f_{id}$ is a static method of the enclosing class $C$, $i$ is equ
ivalent to $C.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})
$. | 3156 Otherwise, if $f_{id}$ is a static method of the enclosing class $C$, $i$ is equ
ivalent to $C.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})
$. |
3124 \item Otherwise, $f_{id}$ is considered equivalent to the ordinary method invoca
tion $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})
$. | 3157 \item Otherwise, $f_{id}$ is considered equivalent to the ordinary method invoca
tion $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})
$. |
3125 \end{itemize} | 3158 \end{itemize} |
3126 | 3159 |
3127 %Otherwise, if there is an accessible (\ref{privacy}) static method named $id$ d
eclared in a superclass $S$ of the immediately enclosing class $C$ then i is equ
ivalent to the static method invocation $S.id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}
, \ldots, x_{n+k}: a_{n+k})$. | 3160 %Otherwise, if there is an accessible (\ref{privacy}) static method named $id$ d
eclared in a superclass $S$ of the immediately enclosing class $C$ then i is equ
ivalent to the static method invocation $S.id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}
, \ldots, x_{n+k}: a_{n+k})$. |
3128 | 3161 |
3129 %\rationale{ | 3162 %\rationale{ |
3130 %Unqualified access to static methods of superclasses is inconsistent with the i
dea that static methods are not inherited. It is not particularly necessary and
may be restricted in future versions. | 3163 %Unqualified access to static methods of superclasses is inconsistent with the i
dea that static methods are not inherited. It is not particularly necessary and
may be restricted in future versions. |
3131 %} | 3164 %} |
3132 | 3165 |
3133 Otherwise, if $i$ occurs inside a top level or static function (be it function,
method, getter, or setter) or variable initializer, evaluation of $i$ causes a
\cd{NoSuchMethodError} to be thrown. | 3166 Otherwise, if $i$ occurs inside a top level or static function (be it function,
method, getter, or setter) or variable initializer, evaluation of $i$ causes a
\cd{NoSuchMethodError} to be thrown. |
3134 | 3167 |
3135 If $i$ does not occur inside a top level or static function, $i$ is equivalent t
o $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. | 3168 If $i$ does not occur inside a top level or static function, $i$ is equivalent t
o $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. |
3136 | 3169 |
| 3170 % Should also say: |
| 3171 % It is a static warning if $i$ occurs inside a top level or static function (b
e it function, method, getter, or setter) or variable initializer and there is
no lexically visible declaration named $id$ in scope. |
| 3172 |
| 3173 |
| 3174 |
3137 | 3175 |
3138 | 3176 |
3139 \subsubsection{ Function Expression Invocation} | 3177 \subsubsection{ Function Expression Invocation} |
3140 \label{functionExpressionInvocation} | 3178 \label{functionExpressionInvocation} |
3141 | 3179 |
3142 A function expression invocation $i$ has the form | 3180 A function expression invocation $i$ has the form |
3143 | 3181 |
3144 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, | 3182 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, |
3145 | 3183 |
3146 where $e_f$ is an expression. If $e_f$ is an identifier $id$, then $id$ must nec
essarily denote a local function, a library function, a library or static getter
or a variable as described above, or $i$ is not considered a function expressio
n invocation. If $e_f$ is a property extraction expression (\ref{propertyExtract
ion}), then $i$ is is not a function expression invocation and is instead recogn
ized as an ordinary method invocation (\ref{ordinaryInvocation}). | 3184 where $e_f$ is an expression. If $e_f$ is an identifier $id$, then $id$ must nec
essarily denote a local function, a library function, a library or static getter
or a variable as described above, or $i$ is not considered a function expressio
n invocation. If $e_f$ is a property extraction expression (\ref{propertyExtract
ion}), then $i$ is is not a function expression invocation and is instead recogn
ized as an ordinary method invocation (\ref{ordinaryInvocation}). |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3543 | 3581 |
3544 | 3582 |
3545 {\bf logicalAndExpression:} | 3583 {\bf logicalAndExpression:} |
3546 equalityExpression (`\&\&' equalityExpression)* | 3584 equalityExpression (`\&\&' equalityExpression)* |
3547 % bitwiseOrExpression (`\&\&' bitwiseOrExpression)* | 3585 % bitwiseOrExpression (`\&\&' bitwiseOrExpression)* |
3548 . | 3586 . |
3549 \end{grammar} | 3587 \end{grammar} |
3550 | 3588 |
3551 A {\em logical boolean expression} is either an equality expression (\ref{equali
ty}), or an invocation of a logical boolean operator on an expression $e_1$ with
argument $e_2$. | 3589 A {\em logical boolean expression} is either an equality expression (\ref{equali
ty}), or an invocation of a logical boolean operator on an expression $e_1$ with
argument $e_2$. |
3552 | 3590 |
3553 Evaluation of a logical boolean expression $b$ of the form $e_1 || e_2$ causes t
he evaluation of $e_1$; if $e_1$ evaluates to true, the result of evaluating $b$
is true, otherwise $e_2$ is evaluated to an object $o$, which is then subjected
to boolean conversion (\ref{booleanConversion}) producing an object $r$, which
is the value of $b$. | 3591 Evaluation of a logical boolean expression $b$ of the form $e_1 || e_2$ causes t
he evaluation of $e_1$ and then subjected to boolean conversion, yielding an obj
ect $o_1$; if $o_1$ is true, the result of evaluating $b$ is true, otherwise $e_
2$ is evaluated to an object $o_2$, which is then subjected to boolean conversio
n (\ref{booleanConversion}) producing an object $r$, which is the value of $b$. |
3554 | 3592 |
3555 Evaluation of a logical boolean expression $b$ of the form $e_1 \&\& e_2$ causes
the evaluation of $e_1$; if $e_1$ does not evaluate to true, the result of eval
uating $b$ is false, otherwise $e_2$ is evaluated to an object $o$, which is the
n subjected to boolean conversion producing an object $r$, which is the value of
$b$. | 3593 Evaluation of a logical boolean expression $b$ of the form $e_1 \&\& e_2$ causes
the evaluation of $e_1$ and then subjected to boolean conversion, yielding an o
bject $o_1$; if $o_1$ is not true, the result of evaluating $b$ is false, other
wise $e_2$ is evaluated to an object $o_2$, which is then subjected to boolean c
onversion producing an object $r$, which is the value of $b$. |
3556 | 3594 |
3557 A logical boolean expression $b$ of the form $e_1 \&\& e_2$ shows that a variabl
e $v$ has type | 3595 A logical boolean expression $b$ of the form $e_1 \&\& e_2$ shows that a variabl
e $v$ has type |
3558 $T$ if all of the following conditions hold: | 3596 $T$ if all of the following conditions hold: |
3559 \begin{itemize} | 3597 \begin{itemize} |
3560 \item Either $e_1$ shows that $v$ has type $T$ or $e_2$ shows that $v$ has type
$T$. | 3598 \item Either $e_1$ shows that $v$ has type $T$ or $e_2$ shows that $v$ has type
$T$. |
3561 \item $v$ is a local variable or formal parameter. | 3599 \item $v$ is a local variable or formal parameter. |
3562 \item The variable $v$ is not mutated in $e_2$ or within a closure. | 3600 \item The variable $v$ is not mutated in $e_2$ or within a closure. |
3563 \end{itemize} | 3601 \end{itemize} |
3564 | 3602 |
3565 Furthermore, if all of the following hold: | 3603 Furthermore, if all of the following hold: |
3566 \begin{itemize} | 3604 \begin{itemize} |
3567 \item $e_1$ shows that $v$ has type $T$. | 3605 \item $e_1$ shows that $v$ has type $T$. |
3568 \item $v$ is not mutated in either $e_1$, $e_2$ or within a closure. | 3606 \item $v$ is not mutated in either $e_1$, $e_2$ or within a closure. |
3569 \item If the variable $v$ is accessed by a closure in $e_2$ then the variable $v
$ is not potentially mutated anywhere in the scope of $v$. | 3607 \item If the variable $v$ is accessed by a closure in $e_2$ then the variable $v
$ is not potentially mutated anywhere in the scope of $v$. |
3570 \end{itemize} | 3608 \end{itemize} |
3571 then the type of $v$ is known to be $T$ in $e_2$. | 3609 then the type of $v$ is known to be $T$ in $e_2$. |
3572 | 3610 |
3573 It is a static warning if the static types of both $e_1$ and $e_2$ may not be as
signed to \cd{bool}. The static type of a logical boolean expression is \code{bo
ol}. | 3611 It is a static warning if the static type of $e_1$ may not be assigned to \cd{bo
ol} or if the static type of $e_2$ may not be assigned to \cd{bool}. The static
type of a logical boolean expression is \code{bool}. |
3574 | 3612 |
3575 | 3613 |
3576 \subsection{ Equality} | 3614 \subsection{ Equality} |
3577 \label{equality} | 3615 \label{equality} |
3578 | 3616 |
3579 Equality expressions test objects for equality. | 3617 Equality expressions test objects for equality. |
3580 | 3618 |
3581 \begin{grammar} | 3619 \begin{grammar} |
3582 {\bf equalityExpression:}relationalExpression (equalityOperator relationalExpres
sion)?; | 3620 {\bf equalityExpression:}relationalExpression (equalityOperator relationalExpres
sion)?; |
3583 \SUPER{} equalityOperator relationalExpression | 3621 \SUPER{} equalityOperator relationalExpression |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4460 it is a compile-time error if the expressions $e_k$ are not compile-time consta
nts for all $k \in 1..n$. It is a compile-time error if the values of the expr
essions $e_k$ are not either: | 4498 it is a compile-time error if the expressions $e_k$ are not compile-time consta
nts for all $k \in 1..n$. It is a compile-time error if the values of the expr
essions $e_k$ are not either: |
4461 \begin{itemize} | 4499 \begin{itemize} |
4462 \item instances of the same class $C$, for all $k \in 1..n$, or | 4500 \item instances of the same class $C$, for all $k \in 1..n$, or |
4463 \item instances of a class that implements \cd{int}, for all $k \in 1..n$, or | 4501 \item instances of a class that implements \cd{int}, for all $k \in 1..n$, or |
4464 \item instances of a class that implements \cd{String}, for all $k \in 1..n$. | 4502 \item instances of a class that implements \cd{String}, for all $k \in 1..n$. |
4465 \end{itemize} | 4503 \end{itemize} |
4466 | 4504 |
4467 \commentary{In other words, all the expressions in the cases evaluate to consta
nts of the exact same user defined class or are of certain known types. Note th
at the values of the expressions are known at compile-time, and are independent
of any static type annotations. | 4505 \commentary{In other words, all the expressions in the cases evaluate to consta
nts of the exact same user defined class or are of certain known types. Note th
at the values of the expressions are known at compile-time, and are independent
of any static type annotations. |
4468 } | 4506 } |
4469 | 4507 |
4470 It is a compile-time error if the class $C$ has an implementation of the operato
r $==$ other than the one inherited from \code{Object} unless the value of the e
xpression is a string or an integer. | 4508 It is a compile-time error if the class $C$ has an implementation of the operato
r $==$ other than the one inherited from \code{Object} unless the value of the e
xpression is a string, an integer, literal symbol or the result of invoking a co
nstant constructor class \cd{Symbol}. |
4471 | 4509 |
4472 \rationale{ | 4510 \rationale{ |
4473 The prohibition on user defined equality allows us to implement the switch effi
ciently for user defined types. We could formulate matching in terms of identity
instead with the same efficiency. However, if a type defines an equality operat
or, programmers would find it quite surprising that equal objects did not match. | 4511 The prohibition on user defined equality allows us to implement the switch effi
ciently for user defined types. We could formulate matching in terms of identity
instead with the same efficiency. However, if a type defines an equality operat
or, programmers would find it quite surprising that equal objects did not match. |
4474 | 4512 |
4475 } | 4513 } |
4476 | 4514 |
4477 \commentary{ | 4515 \commentary{ |
4478 The \SWITCH{} statement should only be used in very limited situations (e.g., i
nterpreters or scanners). | 4516 The \SWITCH{} statement should only be used in very limited situations (e.g., i
nterpreters or scanners). |
4479 } | 4517 } |
4480 | 4518 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4704 | 4742 |
4705 The statement $s_1$ is executed in the dynamic scope of the exception handler de
fined by the try statement. Then, the \FINALLY{} clause is executed. | 4743 The statement $s_1$ is executed in the dynamic scope of the exception handler de
fined by the try statement. Then, the \FINALLY{} clause is executed. |
4706 | 4744 |
4707 \commentary{ | 4745 \commentary{ |
4708 Whether any of the \ON{}-\CATCH{} clauses is executed depends on whether a match
ing exception has been raised by $s_1$ (see the specification of the throw state
ment). | 4746 Whether any of the \ON{}-\CATCH{} clauses is executed depends on whether a match
ing exception has been raised by $s_1$ (see the specification of the throw state
ment). |
4709 | 4747 |
4710 If $s_1$ has raised an exception, it will transfer control to the try statement'
s handler, which will examine the catch clauses in order for a match as specifie
d above. If no matches are found, the handler will execute the \FINALLY{} clause
. | 4748 If $s_1$ has raised an exception, it will transfer control to the try statement'
s handler, which will examine the catch clauses in order for a match as specifie
d above. If no matches are found, the handler will execute the \FINALLY{} clause
. |
4711 | 4749 |
4712 If a matching \ON{}-\CATCH{} was found, it will execute first, and then the \FIN
ALLY{} clause will be executed. | 4750 If a matching \ON{}-\CATCH{} was found, it will execute first, and then the \FIN
ALLY{} clause will be executed. |
4713 | 4751 |
4714 If an exception is raised during execution of an \ON{}-\CATCH{} clause, this wil
l transfer control to the handler for the \FINALLY{} clause, causing the \FINALL
Y{} clause to execute in this case as well. | 4752 If an exception is thrown during execution of an \ON{}-\CATCH{} clause, this wil
l transfer control to the handler for the \FINALLY{} clause, causing the \FINALL
Y{} clause to execute in this case as well. |
4715 | 4753 |
4716 If no exception was raised, the \FINALLY{} clause is also executed. Execution of
the \FINALLY{} clause could also raise an exception, which will cause transfer
of control to the next enclosing handler. | 4754 If no exception was raised, the \FINALLY{} clause is also executed. Execution of
the \FINALLY{} clause could also raise an exception, which will cause transfer
of control to the next enclosing handler. |
4717 } | 4755 } |
4718 | 4756 |
4719 A try statement of the form \code{\TRY{} $s_1$ $on-catch_1 \ldots on-catch_n$;}
is equivalent to the statement \code{\TRY{} $s_1$ $on-catch_1 \ldots on-catch_n$
\FINALLY{} $\{\}$;}. | 4757 A try statement of the form \code{\TRY{} $s_1$ $on-catch_1 \ldots on-catch_n$;}
is equivalent to the statement \code{\TRY{} $s_1$ $on-catch_1 \ldots on-catch_n$
\FINALLY{} $\{\}$;}. |
4720 | 4758 |
4721 | 4759 |
4722 \subsection{ Return} | 4760 \subsection{ Return} |
4723 \label{return} | 4761 \label{return} |
4724 | 4762 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5043 | 5081 |
5044 \rationale { | 5082 \rationale { |
5045 Whereas normal conflicts are resolved at deployment time, the functionality of \
code{dart:} libraries is injected into an application at run time, and may vary
over time as browsers are upgraded. Thus, conflicts with \code{dart:} libraries
can arise at runtime, outside the developerÕs control. To avoid breaking deploy
ed applications in this way, conflicts with the \code{dart:} libraries are treat
ed specially. | 5083 Whereas normal conflicts are resolved at deployment time, the functionality of \
code{dart:} libraries is injected into an application at run time, and may vary
over time as browsers are upgraded. Thus, conflicts with \code{dart:} libraries
can arise at runtime, outside the developerÕs control. To avoid breaking deploy
ed applications in this way, conflicts with the \code{dart:} libraries are treat
ed specially. |
5046 | 5084 |
5047 It is recommended that tools that deploy Dart code produce output in which all i
mports use show clauses to ensure that additions to the namespace of a library n
ever impact deployed code. | 5085 It is recommended that tools that deploy Dart code produce output in which all i
mports use show clauses to ensure that additions to the namespace of a library n
ever impact deployed code. |
5048 } | 5086 } |
5049 | 5087 |
5050 If a name $N$ is referenced by a library $L$ and $N$ is introduced into the to
p level scope of $L$ by more than one import, and not all the imports denote the
same declaration, then: | 5088 If a name $N$ is referenced by a library $L$ and $N$ is introduced into the to
p level scope of $L$ by more than one import, and not all the imports denote the
same declaration, then: |
5051 \begin{itemize} | 5089 \begin{itemize} |
5052 \item A static warning occurs. | 5090 \item A static warning occurs. |
5053 \item If $N$ is referenced as a function, getter or setter, a \code{NoSuchMethod
Error} is raised. | 5091 \item If $N$ is referenced as a function, getter or setter, a \code{NoSuchMethod
Error} is thrown. |
5054 \item If $N$ is referenced as a type, it is treated as a malformed type. | 5092 \item If $N$ is referenced as a type, it is treated as a malformed type. |
5055 | 5093 |
5056 \end{itemize} | 5094 \end{itemize} |
5057 | 5095 |
5058 We say that the namespace $NS$ {\em has been imported into} $L$. | 5096 We say that the namespace $NS$ {\em has been imported into} $L$. |
5059 | 5097 |
5060 \commentary{ | 5098 \commentary{ |
5061 It is neither an error nor a warning if $N$ is introduced by two or more import
s but never referred to. | 5099 It is neither an error nor a warning if $N$ is introduced by two or more import
s but never referred to. |
5062 } | 5100 } |
5063 | 5101 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5613 \rationale{From a usability perspective, we want to ensure that the checker does
not issue errors everywhere an unknown type is used. The definitions above ensu
re that no secondary errors are reported when accessing an unknown type. | 5651 \rationale{From a usability perspective, we want to ensure that the checker does
not issue errors everywhere an unknown type is used. The definitions above ensu
re that no secondary errors are reported when accessing an unknown type. |
5614 | 5652 |
5615 The current rules say that missing type arguments are treated as if they were th
e type \DYNAMIC{}. An alternative is to consider them as meaning \code{Object}
. This would lead to earlier error detection in checked mode, and more aggressi
ve errors during static typechecking. For example: | 5653 The current rules say that missing type arguments are treated as if they were th
e type \DYNAMIC{}. An alternative is to consider them as meaning \code{Object}
. This would lead to earlier error detection in checked mode, and more aggressi
ve errors during static typechecking. For example: |
5616 | 5654 |
5617 (1) \code{typedAPI(G\lt{String}\gt g)\{...\}} | 5655 (1) \code{typedAPI(G\lt{String}\gt g)\{...\}} |
5618 | 5656 |
5619 | 5657 |
5620 (2) \code{typedAPI(new G()); } | 5658 (2) \code{typedAPI(new G()); } |
5621 | 5659 |
5622 | 5660 |
5623 Under the alternative rules, (2) would cause a runtime error in checked mode. Th
is seems desirable from the perspective of error localization. However, when a d
ynamic error is raised at (2), the only way to keep running is rewriting (2) int
o | 5661 Under the alternative rules, (2) would cause a runtime error in checked mode. Th
is seems desirable from the perspective of error localization. However, when a d
ynamic error is thrown at (2), the only way to keep running is rewriting (2) int
o |
5624 | 5662 |
5625 (3) \code{typedAPI(new G\lt{String}\gt());} | 5663 (3) \code{typedAPI(new G\lt{String}\gt());} |
5626 | 5664 |
5627 This forces users to write type information in their client code just because th
ey are calling a typed API. We do not want to impose this on Dart programmers,
some of which may be blissfully unaware of types in general, and genericity in p
articular. | 5665 This forces users to write type information in their client code just because th
ey are calling a typed API. We do not want to impose this on Dart programmers,
some of which may be blissfully unaware of types in general, and genericity in p
articular. |
5628 | 5666 |
5629 What of static checking? Surely we would want to flag (2) when users have explic
itly asked for static typechecking? Yes, but the reality is that the Dart static
checker is likely to be running in the background by default. Engineering teams
typically desire a ``clean build'' free of warnings and so the checker is desig
ned to be extremely charitable. Other tools can interpret the type information m
ore aggressively and warn about violations of conventional (and sound) static ty
pe discipline. | 5667 What of static checking? Surely we would want to flag (2) when users have explic
itly asked for static typechecking? Yes, but the reality is that the Dart static
checker is likely to be running in the background by default. Engineering teams
typically desire a ``clean build'' free of warnings and so the checker is desig
ned to be extremely charitable. Other tools can interpret the type information m
ore aggressively and warn about violations of conventional (and sound) static ty
pe discipline. |
5630 } | 5668 } |
5631 | 5669 |
5632 The name \DYNAMIC{} denotes a \cd{Type} object even though \DYNAMIC{} is not a c
lass. | 5670 The name \DYNAMIC{} denotes a \cd{Type} object even though \DYNAMIC{} is not a c
lass. |
5633 | 5671 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5888 \item The names of compile time constant variables never use lower case letters.
If they consist of multiple words, those words are separated by underscores. Ex
amples: PI, I\_AM\_A\_CONSTANT. | 5926 \item The names of compile time constant variables never use lower case letters.
If they consist of multiple words, those words are separated by underscores. Ex
amples: PI, I\_AM\_A\_CONSTANT. |
5889 \item The names of functions (including getters, setters, methods and local or l
ibrary functions) and non-constant variables begin with a lowercase letter. If t
he name consists of multiple words, each word (except the first) begins with an
uppercase letter. No other uppercase letters are used. Examples: camlCase, dar
t4TheWorld | 5927 \item The names of functions (including getters, setters, methods and local or l
ibrary functions) and non-constant variables begin with a lowercase letter. If t
he name consists of multiple words, each word (except the first) begins with an
uppercase letter. No other uppercase letters are used. Examples: camlCase, dar
t4TheWorld |
5890 \item The names of types (including classes and type aliases) begin with an uppe
r case letter. If the name consists of multiple words, each word begins with
an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D
art4TheWorld. | 5928 \item The names of types (including classes and type aliases) begin with an uppe
r case letter. If the name consists of multiple words, each word begins with
an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D
art4TheWorld. |
5891 \item The names of type variables are short (preferably single letter). Examples
: T, S, K, V , E. | 5929 \item The names of type variables are short (preferably single letter). Examples
: T, S, K, V , E. |
5892 \item The names of libraries or library prefixes never use upper case letters. I
f they consist of multiple words, those words are separated by underscores. Exam
ple: my\_favorite\_library. | 5930 \item The names of libraries or library prefixes never use upper case letters. I
f they consist of multiple words, those words are separated by underscores. Exam
ple: my\_favorite\_library. |
5893 \end{itemize} | 5931 \end{itemize} |
5894 } | 5932 } |
5895 | 5933 |
5896 | 5934 |
5897 \end{document} | 5935 \end{document} |
OLD | NEW |