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

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

Issue 2843733002: Adjusted initializer rules, changing a run-time error to compile-time. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 \documentclass{article} 1 \documentclass{article}
2 \usepackage{epsfig} 2 \usepackage{epsfig}
3 \usepackage{color} 3 \usepackage{color}
4 \usepackage{dart} 4 \usepackage{dart}
5 \usepackage{bnf} 5 \usepackage{bnf}
6 \usepackage{hyperref} 6 \usepackage{hyperref}
7 \usepackage{lmodern} 7 \usepackage{lmodern}
8 \usepackage[T1]{fontenc} 8 \usepackage[T1]{fontenc}
9 \newcommand{\code}[1]{{\sf #1}} 9 \newcommand{\code}[1]{{\sf #1}}
10 \title{Dart Programming Language Specification \\ 10 \title{Dart Programming Language Specification \\
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 fieldInitializer 1404 fieldInitializer
1405 . 1405 .
1406 1406
1407 {\bf fieldInitializer:} 1407 {\bf fieldInitializer:}
1408 (\THIS{} `{\escapegrammar .}')? identifier `=' conditionalExpression casca deSection* 1408 (\THIS{} `{\escapegrammar .}')? identifier `=' conditionalExpression casca deSection*
1409 . 1409 .
1410 1410
1411 \end{grammar} 1411 \end{grammar}
1412 1412
1413 \LMHash{} 1413 \LMHash{}
1414 Let $k$ be a generative constructor. Then $k$ may include at most one superini tializer in its initializer list or a compile-time error occurs. If no superinit ializer is provided, an implicit superinitializer of the form \SUPER{}() is adde d at the end of $k$'s initializer list, unless the enclosing class is class \cod e{Object}. It is a compile-time error if more than one initializer corresponding to a given instance variable appears in $k$'s initializer list. It is a compile -time error if $k$'s initializer list contains an initializer for a variable tha t is initialized by means of an initializing formal of $k$. % It is a compile-ti me error if $k$'s initializer list contains an initializer for a final variable $f$ whose declaration includes an initialization expression. 1414 Let $k$ be a generative constructor.
1415 Then $k$ may include at most one superinitializer in its initializer list or a c ompile-time error occurs.
1416 If no superinitializer is provided, an implicit superinitializer of the form \SU PER{}() is added at the end of $k$'s initializer list,
1417 unless the enclosing class is class \code{Object}.
1418 It is a compile-time error if more than one initializer corresponding to a given instance variable appears in $k$'s initializer list.
1419 It is a compile-time error if $k$'s initializer list contains an initializer for a variable that is initialized by means of an initializing formal of $k$.
Lasse Reichstein Nielsen 2017/04/25 16:00:23 Interesting that this is an error, even if it's no
eernst 2017/05/19 11:17:02 Acknowledged. I think the clashes "2 initializers"
1420 It is a compile-time error if $k$'s initializer list contains an initializer for a final variable $f$ whose declaration includes an initialization expression.
Lasse Reichstein Nielsen 2017/04/25 16:00:23 Should we handle the case of initializing formal +
eernst 2017/05/19 11:17:02 Yep, that's (now) a name clash in the formal param
1415 1421
1416 \LMHash{} 1422 \LMHash{}
1417 Each final instance variable $f$ declared in the immediately enclosing class mus t have an initializer in $k$'s initializer list unless it has already been initi alized by one of the following means: 1423 Each final instance variable $f$ declared in the immediately enclosing class mus t have an initializer in $k$'s initializer list unless it has already been initi alized by one of the following means:
1418 \begin{itemize} 1424 \begin{itemize}
1419 \item Initialization at the declaration of $f$. 1425 \item Initialization at the declaration of $f$.
1420 \item Initialization by means of an initializing formal of $k$. 1426 \item Initialization by means of an initializing formal of $k$.
1421 \end{itemize} 1427 \end{itemize}
1422 1428
1423 or a static warning occurs. It is a compile-time error if $k$'s initializer list contains an initializer for a variable that is not an instance variable declare d in the immediately surrounding class. 1429 or a static warning occurs. It is a compile-time error if $k$'s initializer list contains an initializer for a variable that is not an instance variable declare d in the immediately surrounding class.
1424 1430
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 an instance method cannot be directly invoked, nor can \THIS{} be passed into an y other code being invoked in the initializer. 1496 an instance method cannot be directly invoked, nor can \THIS{} be passed into an y other code being invoked in the initializer.
1491 } 1497 }
1492 1498
1493 \LMHash{} 1499 \LMHash{}
1494 During the execution of a generative constructor to initialize an instance $i$, 1500 During the execution of a generative constructor to initialize an instance $i$,
1495 execution of an initializer of the form \code{\THIS{}.$v$ = $e$} 1501 execution of an initializer of the form \code{\THIS{}.$v$ = $e$}
1496 proceeds as follows: 1502 proceeds as follows:
1497 1503
1498 \LMHash{} 1504 \LMHash{}
1499 First, the expression $e$ is evaluated to an object $o$. 1505 First, the expression $e$ is evaluated to an object $o$.
1500 %%STRONG_MODE: The runtime error in the next sentence will be compile-time. 1506 Then, the instance variable $v$ of $i$ is bound to $o$.
1501 Then, the instance variable $v$ of $i$ is bound to $o$, unless $v$ is a final va riable that has already been initialized, in which case a runtime error occurs.
1502 In checked mode, it is a dynamic type error if $o$ is not \NULL{} and the interf ace of the class of $o$ is not a subtype of the actual type of the instance vari able $v$. 1507 In checked mode, it is a dynamic type error if $o$ is not \NULL{} and the interf ace of the class of $o$ is not a subtype of the actual type of the instance vari able $v$.
1503 1508
1504 \LMHash{} 1509 \LMHash{}
1505 An initializer of the form \code{$v$ = $e$} is equivalent to an initializer of t he form \code{\THIS{}.$v$ = $e$}. 1510 An initializer of the form \code{$v$ = $e$} is equivalent to an initializer of t he form \code{\THIS{}.$v$ = $e$}.
1506 1511
1507 \LMHash{} 1512 \LMHash{}
1508 Execution of a superinitializer of the form 1513 Execution of a superinitializer of the form
1509 1514
1510 \SUPER{}$(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$ 1515 \SUPER{}$(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$
1511 1516
(...skipping 6632 matching lines...) Expand 10 before | Expand all | Expand 10 after
8144 8149
8145 The invariant that each normative paragraph is associated with a line 8150 The invariant that each normative paragraph is associated with a line
8146 containing the text \LMHash{} should be maintained. Extra occurrences 8151 containing the text \LMHash{} should be maintained. Extra occurrences
8147 of \LMHash{} can be added if needed, e.g., in order to make 8152 of \LMHash{} can be added if needed, e.g., in order to make
8148 individual \item{}s in itemized lists addressable. Each \LM.. command 8153 individual \item{}s in itemized lists addressable. Each \LM.. command
8149 must occur on a separate line. \LMHash{} must occur immediately 8154 must occur on a separate line. \LMHash{} must occur immediately
8150 before the associated paragraph, and \LMLabel must occur immediately 8155 before the associated paragraph, and \LMLabel must occur immediately
8151 after the associated \section{}, \subsection{} etc. 8156 after the associated \section{}, \subsection{} etc.
8152 8157
8153 ---------------------------------------------------------------------- 8158 ----------------------------------------------------------------------
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