OLD | NEW |
1 \documentclass{article} | 1 \documentclass{article} |
2 \usepackage{epsfig} | 2 \usepackage{epsfig} |
3 \usepackage{color} | 3 \usepackage{color} |
4 \usepackage{dart} | 4 \usepackage{dart} |
5 \usepackage{bnf} | 5 \usepackage{bnf} |
6 \usepackage{hyperref} | 6 \usepackage{hyperref} |
7 \usepackage{lmodern} | 7 \usepackage{lmodern} |
8 \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 \\ |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 \LMHash{} | 1231 \LMHash{} |
1232 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. | 1232 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. |
1233 | 1233 |
1234 \begin{grammar} | 1234 \begin{grammar} |
1235 {\bf constructorSignature:} | 1235 {\bf constructorSignature:} |
1236 identifier (`{\escapegrammar .}' identifier)? formalParameterList | 1236 identifier (`{\escapegrammar .}' identifier)? formalParameterList |
1237 . | 1237 . |
1238 \end{grammar} | 1238 \end{grammar} |
1239 | 1239 |
1240 \LMHash{} | 1240 \LMHash{} |
1241 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 $id$ is the name of an
instance variable of the immediately enclosing class. It is a compile-time erro
r if \code{id} is not an instance variable of the immediately enclosing class. I
t is a compile-time error if an initializing formal is used by a function other
than a non-redirecting generative constructor. | 1241 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 $id$ is the name of an
instance variable of the immediately enclosing class. It is a compile-time erro
r if $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 other than
a non-redirecting generative constructor. |
1242 | 1242 |
1243 \LMHash{} | 1243 \LMHash{} |
1244 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}$. | 1244 If an explicit type is attached to the initializing formal, that is its static t
ype. Otherwise, the type of an initializing formal named $id$ is $T_{id}$, where
$T_{id}$ is the type of the field named $id$ in the immediately enclosing class
. It is a static warning if the static type of $id$ is not assignable to $T_{id}
$. |
1245 | 1245 |
1246 \LMHash{} | 1246 \LMHash{} |
1247 Initializing formals constitute an exception to the rule that every formal param
eter introduces a local variable into the formal parameter scope (\ref{formalPar
ameters}). | 1247 Initializing formals constitute an exception to the rule that every formal param
eter introduces a local variable into the formal parameter scope (\ref{formalPar
ameters}). |
1248 When the formal parameter list of a non-redirecting generative constructor conta
ins any initializing formals, a new scope is introduced, the {\em formal paramet
er initializer scope}, which is the current scope of the initializer list of the
constructor, and which is enclosed in the scope where the constructor is declar
ed. | 1248 When the formal parameter list of a non-redirecting generative constructor conta
ins any initializing formals, a new scope is introduced, the {\em formal paramet
er initializer scope}, which is the current scope of the initializer list of the
constructor, and which is enclosed in the scope where the constructor is declar
ed. |
1249 Each initializing formal in the formal parameter list introduces a final local v
ariable into the formal parameter initializer scope, but not into the formal par
ameter scope; every other formal parameter introduces a local variable into both
the formal parameter scope and the formal parameter initializer scope. | 1249 Each initializing formal in the formal parameter list introduces a final local v
ariable into the formal parameter initializer scope, but not into the formal par
ameter scope; every other formal parameter introduces a local variable into both
the formal parameter scope and the formal parameter initializer scope. |
1250 | 1250 |
1251 \commentary{ | 1251 \commentary{ |
1252 This means that formal parameters, including initializing formals, must have dis
tinct names, and that initializing formals are in scope for the initializer list
, but they are not in scope for the body of the constructor. | 1252 This means that formal parameters, including initializing formals, must have dis
tinct names, and that initializing formals are in scope for the initializer list
, but they are not in scope for the body of the constructor. |
1253 When a formal parameter introduces a local variable into two scopes, it is still
one variable and hence one storage location. | 1253 When a formal parameter introduces a local variable into two scopes, it is still
one variable and hence one storage location. |
1254 The type of the constructor is defined in terms of its formal parameters, includ
ing the initializing formals. | 1254 The type of the constructor is defined in terms of its formal parameters, includ
ing the initializing formals. |
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3147 | 3147 |
3148 In any other circumstance, $flatten(T) = T$. | 3148 In any other circumstance, $flatten(T) = T$. |
3149 | 3149 |
3150 | 3150 |
3151 | 3151 |
3152 \rationale{ | 3152 \rationale{ |
3153 We collapse multiple layers of futures into one. If $e$ evaluates to a future $f
$, the future will not invoke its \code{then()} callback until f completes to a
non-future value, and so the result of an await is never a future, and the resul
t of an async function will never have type \code{Future$<X>$} where $X$ itself
is an invocation of \code{Future}. | 3153 We collapse multiple layers of futures into one. If $e$ evaluates to a future $f
$, the future will not invoke its \code{then()} callback until f completes to a
non-future value, and so the result of an await is never a future, and the resul
t of an async function will never have type \code{Future$<X>$} where $X$ itself
is an invocation of \code{Future}. |
3154 | 3154 |
3155 The exception to that would be a type $X$ that extended or implemented \code{Fu
ture}. In that case, only one unwrapping takes place. As an example of why this
is done, consider | 3155 The exception to that would be a type $X$ that extended or implemented \code{Fu
ture}. In that case, only one unwrapping takes place. As an example of why this
is done, consider |
3156 | 3156 |
3157 \cd{\CLASS{} C<T> \IMPLEMENTS{} Future<C<C<T$>>>$ \ldots } | 3157 \cd{\CLASS{} C<T> \IMPLEMENTS{} Future<C<C<T>>> \ldots } |
3158 | 3158 |
3159 Here, a naive definition of $flatten$ diverges; there is not even a fixed point.
A more sophisticated definition of $flatten$ is possible, but the existing rule
deals with most realistic examples while remaining relatively simple to underst
and. | 3159 Here, a naive definition of $flatten$ diverges; there is not even a fixed point.
A more sophisticated definition of $flatten$ is possible, but the existing rule
deals with most realistic examples while remaining relatively simple to underst
and. |
3160 | 3160 |
3161 } | 3161 } |
3162 | 3162 |
3163 | 3163 |
3164 \LMHash{} | 3164 \LMHash{} |
3165 The static type of a function literal of the form | 3165 The static type of a function literal of the form |
3166 | 3166 |
3167 $(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_
{n+k} = d_k\}) => e$ | 3167 $(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_
{n+k} = d_k\}) => e$ |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3706 An unqualified function invocation $i$ has the form | 3706 An unqualified function invocation $i$ has the form |
3707 | 3707 |
3708 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, | 3708 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, |
3709 | 3709 |
3710 where $id$ is an identifier. | 3710 where $id$ is an identifier. |
3711 | 3711 |
3712 \LMHash{} | 3712 \LMHash{} |
3713 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the
innermost such declaration. Then: | 3713 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the
innermost such declaration. Then: |
3714 \begin{itemize} | 3714 \begin{itemize} |
3715 \item | 3715 \item |
| 3716 If $id$ is a type literal, then $i$ is interpreted as a function expression invo
cation (ref{functionExpressionInvociation}) with $(id)$ as the expression $e_f$. |
| 3717 \commentary{ |
| 3718 The expression $(id)$ where $id$ is a type literal always evaluates to an instan
ce of class \code{Type} which is not a function. This ensures that a runtime err
or occurs when trying to call a type literal. |
| 3719 } |
| 3720 \item |
3716 If $f_{id}$ is a prefix object, a compile-time error occurs. | 3721 If $f_{id}$ is a prefix object, a compile-time error occurs. |
3717 \item | 3722 \item |
3718 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}). | 3723 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}). |
3719 \item | 3724 \item |
3720 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})
$. | 3725 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})
$. |
3721 \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})
$. | 3726 \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})
$. |
3722 \end{itemize} | 3727 \end{itemize} |
3723 | 3728 |
3724 \LMHash{} | 3729 \LMHash{} |
3725 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. | 3730 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. |
3726 | 3731 |
3727 \LMHash{} | 3732 \LMHash{} |
3728 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})$. | 3733 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})$. |
3729 | 3734 |
3730 | 3735 |
3731 % Should also say: | 3736 % Should also say: |
3732 % 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. | 3737 % 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. |
3733 | 3738 |
3734 | 3739 |
3735 | 3740 |
3736 | 3741 |
3737 | 3742 |
3738 \subsubsection{ Function Expression Invocation} | 3743 \subsubsection{ Function Expression Invocation} |
3739 \LMLabel{functionExpressionInvocation} | 3744 \LMLabel{functionExpressionInvocation} |
3740 | 3745 |
3741 \LMHash{} | 3746 \LMHash{} |
3742 A function expression invocation $i$ has the form | 3747 A function expression invocation $i$ has the form |
3743 | 3748 |
3744 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, | 3749 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, |
3745 | 3750 |
3746 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}). | 3751 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. |
| 3752 If $e_f$ is a type literal, then it is equivalent to the expression $(e_f)$. |
| 3753 |
| 3754 \commentary{ |
| 3755 The expression $(e_f)$ where $e_f$ is a type literal always evaluates to an inst
ance of class \code{Type} which is not a function. This ensures that a runtime e
rror occurs when trying to call a type literal. |
| 3756 } |
| 3757 |
| 3758 If $e_f$ is a property extraction expression (\ref{propertyExtraction}), then $i
$ is is not a function expression invocation and is instead recognized as an ord
inary method invocation (\ref{ordinaryInvocation}). |
3747 | 3759 |
3748 \commentary{ | 3760 \commentary{ |
3749 \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. | 3761 \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. |
3750 } | 3762 } |
3751 | 3763 |
3752 \LMHash{} | 3764 \LMHash{} |
3753 Otherwise: | 3765 Otherwise: |
3754 | 3766 |
3755 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})$. | 3767 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})$. |
3756 | 3768 |
(...skipping 4118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7875 | 7887 |
7876 The invariant that each normative paragraph is associated with a line | 7888 The invariant that each normative paragraph is associated with a line |
7877 containing the text \LMHash{} should be maintained. Extra occurrences | 7889 containing the text \LMHash{} should be maintained. Extra occurrences |
7878 of \LMHash{} can be added if needed, e.g., in order to make | 7890 of \LMHash{} can be added if needed, e.g., in order to make |
7879 individual \item{}s in itemized lists addressable. Each \LM.. command | 7891 individual \item{}s in itemized lists addressable. Each \LM.. command |
7880 must occur on a separate line. \LMHash{} must occur immediately | 7892 must occur on a separate line. \LMHash{} must occur immediately |
7881 before the associated paragraph, and \LMLabel must occur immediately | 7893 before the associated paragraph, and \LMLabel must occur immediately |
7882 after the associated \section{}, \subsection{} etc. | 7894 after the associated \section{}, \subsection{} etc. |
7883 | 7895 |
7884 ---------------------------------------------------------------------- | 7896 ---------------------------------------------------------------------- |
OLD | NEW |