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

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

Issue 2444843002: Make `C()`, where `C` is a class name, a compile-time error. (Closed)
Patch Set: Address previous comment. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 \documentclass{article} 1 \documentclass{article}
2 \usepackage{epsfig} 2 \usepackage{epsfig}
3 \usepackage{color} 3 \usepackage{color}
4 \usepackage{dart} 4 \usepackage{dart}
5 \usepackage{bnf} 5 \usepackage{bnf}
6 \usepackage{hyperref} 6 \usepackage{hyperref}
7 \usepackage{lmodern} 7 \usepackage{lmodern}
8 \usepackage[T1]{fontenc} 8 \usepackage[T1]{fontenc}
9 \newcommand{\code}[1]{{\sf #1}} 9 \newcommand{\code}[1]{{\sf #1}}
10 \title{Dart Programming Language Specification \\ 10 \title{Dart Programming Language Specification \\
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 \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.
eernst 2016/11/17 08:32:31 `\code{id}` --> `$id$`
Lasse Reichstein Nielsen 2016/11/17 08:56:15 Done. Also in the next paragraph. There are more \
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 \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}$.
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{
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 expression (`,' expression)* %should these be top level expressions? 2372 expression (`,' expression)* %should these be top level expressions?
2373 . 2373 .
2374 \end{grammar} 2374 \end{grammar}
2375 2375
2376 \begin{grammar} 2376 \begin{grammar}
2377 {\bf primary:}thisExpression; 2377 {\bf primary:}thisExpression;
2378 \SUPER{} unconditionalAssignableSelector; 2378 \SUPER{} unconditionalAssignableSelector;
2379 functionExpression; 2379 functionExpression;
2380 literal; 2380 literal;
2381 identifier; 2381 identifier;
2382 newExpression; 2382 newExpression;
eernst 2016/11/17 08:32:31 Funny, that line was also removed in https://coder
Lasse Reichstein Nielsen 2016/11/17 08:56:16 Just goes to show that this CL is older than that,
2383 constObjectExpression; 2383 constObjectExpression;
2384 `(' expression `)' 2384 `(' expression `)'
2385 . 2385 .
2386 2386
2387 \end{grammar} 2387 \end{grammar}
2388 2388
2389 \LMHash{} 2389 \LMHash{}
2390 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$. 2390 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$.
2391 2391
2392 \commentary{ 2392 \commentary{
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
eernst 2016/11/17 08:32:31 For consistency, `$>>>$` --> `>>>`.
Lasse Reichstein Nielsen 2016/11/17 08:56:15 Done.
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
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})
eernst 2016/11/17 08:32:31 Missing period at the end.
Lasse Reichstein Nielsen 2016/11/17 08:56:15 Done.
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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
4226 \item 4238 \item
4227 \begin{dartCode} 4239 \begin{dartCode}
4228 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ 4240 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{
4229 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; 4241 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$;
4230 \} 4242 \}
4231 \end{dartCode} 4243 \end{dartCode}
4232 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. 4244 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
4233 \end{itemize} 4245 \end{itemize}
4234 4246
4235 \LMHash{} 4247 \LMHash{}
4236 Except that iff two closurizations were created by code declared in the same cla ss with identical bindings of \THIS{} then \cd{\SUPER$_1.m$ == \SUPER$_2.m$}. 4248 Except that iff two closurizations were created by code declared in the same cla ss with identical bindings of \THIS{} then \cd{\SUPER$_1.m$ == \SUPER$_2.m$}.
eernst 2016/11/17 08:32:31 We should actually keep it at `if` rather than `if
Lasse Reichstein Nielsen 2016/11/17 08:56:15 That's not a change in this CL, so let's discuss t
4237 4249
4238 4250
4239 \subsection{ Assignment} 4251 \subsection{ Assignment}
4240 \LMLabel{assignment} 4252 \LMLabel{assignment}
4241 4253
4242 \LMHash{} 4254 \LMHash{}
4243 An assignment changes the value associated with a mutable variable or property. 4255 An assignment changes the value associated with a mutable variable or property.
4244 4256
4245 \begin{grammar} 4257 \begin{grammar}
4246 {\bf assignmentOperator:}`=' ; 4258 {\bf assignmentOperator:}`=' ;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
4392 4404
4393 \LMHash{} 4405 \LMHash{}
4394 Evaluate $e_1$ to an object $a$, then evaluate $e_2$ to an object $i$, and final ly evaluate $e_3$ to an object $v$. 4406 Evaluate $e_1$ to an object $a$, then evaluate $e_2$ to an object $i$, and final ly evaluate $e_3$ to an object $v$.
4395 Call the method \code{[]=} on $a$ with $i$ as first argument and $v$ as second a rgument. 4407 Call the method \code{[]=} on $a$ with $i$ as first argument and $v$ as second a rgument.
4396 Then $e$ evaluates to $v$. 4408 Then $e$ evaluates to $v$.
4397 4409
4398 \LMHash{} 4410 \LMHash{}
4399 The static type of the expression \code{$e_1$[$e_2$] = $e_3$} is the static type of $e_3$. 4411 The static type of the expression \code{$e_1$[$e_2$] = $e_3$} is the static type of $e_3$.
4400 4412
4401 \LMHash{} 4413 \LMHash{}
4402 An assignment of the form \code{\SUPER[$e_1$] = $e_2$} is equivalent to the expr ession \code{\SUPER.[$e_1$] = $e_2$}. The static type of the expression \code{\ SUPER[$e_1$] = $e_2$} is the static type of $e_2$. 4414 An assignment of the form \code{\SUPER[$e_1$] = $e_2$} is equivalent to the expr ession \code{\SUPER.[$e_1$] = $e_2$}. The static type of the expression \code{\ SUPER[$e_1$] = $e_2$} is the static type of $e_2$.
eernst 2016/11/17 08:32:31 Are you sure there should be a period in `\code{\S
Lasse Reichstein Nielsen 2016/11/17 08:56:15 Yes, this is Gilad's way of treating operators lik
4403 4415
4404 4416
4405 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map. 4417 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map.
4406 4418
4407 \LMHash{} 4419 \LMHash{}
4408 It is a static warning if an assignment of the form $v = e$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer and there is neither a local variable declaration with name $v$ no r setter declaration with name $v=$ in the lexical scope enclosing the assignmen t. 4420 It is a static warning if an assignment of the form $v = e$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer and there is neither a local variable declaration with name $v$ no r setter declaration with name $v=$ in the lexical scope enclosing the assignmen t.
4409 4421
4410 \LMHash{} 4422 \LMHash{}
4411 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 `.'. 4423 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 `.'.
4412 4424
(...skipping 3462 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ----------------------------------------------------------------------
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