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 \\ |
11 {5th edition draft}\\ | 11 {5th edition draft}\\ |
12 {\large Version 2.0.0-dev}} | 12 {\large Version 2.0.0-dev}} |
13 | 13 |
14 % For information about Location Markers (and in particular the | 14 % For information about Location Markers (and in particular the |
15 % commands \LMHash and \LMLabel), see the long comment at the | 15 % commands \LMHash and \LMLabel), see the long comment at the |
16 % end of this file. | 16 % end of this file. |
17 | 17 |
18 % CHANGES | 18 % CHANGES |
19 % ======= | 19 % ======= |
20 % Significant changes to the specification. | 20 % Significant changes to the specification. |
21 % | 21 % |
22 % 2.0 | 22 % 2.0 |
23 % - Don't allow functions as assert test values. | 23 % - Don't allow functions as assert test values. |
| 24 % - It is a static warning and dynamic error to assign to final local. |
24 % | 25 % |
25 % 1.15 | 26 % 1.15 |
26 % - Change how language specification describes control flow. | 27 % - Change how language specification describes control flow. |
27 % - Object initialization now specifies initialization order correctly. | 28 % - Object initialization now specifies initialization order correctly. |
28 % - Specifies that leaving an await-for loop must wait for the subscription | 29 % - Specifies that leaving an await-for loop must wait for the subscription |
29 % to be canceled. | 30 % to be canceled. |
30 % - An await-for loop only pauses the subscription if it does something async. | 31 % - An await-for loop only pauses the subscription if it does something async. |
31 % - Assert statements allows a "message" operand and a trailing comma. | 32 % - Assert statements allows a "message" operand and a trailing comma. |
32 % - The Null type is now considered a subtype of all types in most cases. | 33 % - The Null type is now considered a subtype of all types in most cases. |
33 % - Specify what NEWLINE means in multiline strings. | 34 % - Specify what NEWLINE means in multiline strings. |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 \rationale{The lazy semantics are given because we do not want a language where
one tends to define expensive initialization computations, causing long applicat
ion startup times. This is especially crucial for Dart, which must support the c
oding of client applications. | 442 \rationale{The lazy semantics are given because we do not want a language where
one tends to define expensive initialization computations, causing long applicat
ion startup times. This is especially crucial for Dart, which must support the c
oding of client applications. |
442 } | 443 } |
443 | 444 |
444 \LMHash{} | 445 \LMHash{} |
445 A {\em final variable} is a variable whose binding is fixed upon initialization;
a final variable $v$ will always refer to the same object after $v$ has been in
itialized. The declaration of a final variable must include the modifier \FINAL
{}. | 446 A {\em final variable} is a variable whose binding is fixed upon initialization;
a final variable $v$ will always refer to the same object after $v$ has been in
itialized. The declaration of a final variable must include the modifier \FINAL
{}. |
446 | 447 |
447 \LMHash{} | 448 \LMHash{} |
448 It is a static warning if a final instance variable that has been initialized at
its point of declaration is also initialized in a constructor. | 449 It is a static warning if a final instance variable that has been initialized at
its point of declaration is also initialized in a constructor. |
449 % It is a static warning if a final instance variable that has been initialized
by means of an initializing formal of a constructor is also initialized elsewhe
re in the same constructor. | 450 % It is a static warning if a final instance variable that has been initialized
by means of an initializing formal of a constructor is also initialized elsewhe
re in the same constructor. |
450 It is a compile-time error if a local variable $v$ is final and $v$ is not initi
alized at its point of declaration. | 451 It is a compile-time error if a local variable $v$ is final and $v$ is not initi
alized at its point of declaration. |
| 452 It is a static warning and a dynamic error to assign to a final local variable. |
451 | 453 |
452 \commentary{ | 454 \commentary{ |
453 | 455 |
454 A library or static variable is guaranteed to have an initializer at its declara
tion by the grammar. | 456 A library or static variable is guaranteed to have an initializer at its declara
tion by the grammar. |
455 | 457 |
456 Attempting to assign to a final variable anywhere except in its declaration or i
n a constructor header will cause a runtime error to be thrown as discussed bel
ow. The assignment will also give rise to a static warning. Any repeated assignm
ent to a final variable will also lead to a runtime error. | 458 Attempting to assign to a final variable anywhere except in its declaration or i
n a constructor header will cause a runtime error to be thrown as discussed bel
ow. The assignment will also give rise to a static warning. Any repeated assignm
ent to a final variable will also lead to a runtime error. |
457 | 459 |
458 Taken as a whole, the rules ensure that any attempt to execute multiple assignme
nts to a final variable will yield static warnings and repeated assignments will
fail dynamically. | 460 Taken as a whole, the rules ensure that any attempt to execute multiple assignme
nts to a final variable will yield static warnings and repeated assignments will
fail dynamically. |
459 } | 461 } |
460 | 462 |
(...skipping 5472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5933 % $e$; | 5935 % $e$; |
5934 %\}\} | 5936 %\}\} |
5935 %} | 5937 %} |
5936 | 5938 |
5937 %If $c$ is empty, it is interpreted as \TRUE{}. | 5939 %If $c$ is empty, it is interpreted as \TRUE{}. |
5938 | 5940 |
5939 \subsubsection{For-in} | 5941 \subsubsection{For-in} |
5940 \LMLabel{for-in} | 5942 \LMLabel{for-in} |
5941 | 5943 |
5942 \LMHash{} | 5944 \LMHash{} |
5943 A for statement of the form \code{ \FOR{} ($finalConstVarOrType?$ id \IN{} $e$)
$s$} is equivalent to the following code: | 5945 Let $D$ be derived from \code{finalConstVarOrType?} |
| 5946 and let $n0$ be an identifier that does not occur anywhere in the program. |
| 5947 A for statement of the form \code{\FOR{} ($D$ $id$ \IN{} $e$) $s$} is equivalent
to the following code: |
5944 | 5948 |
5945 \begin{dartCode} | 5949 \begin{dartCode} |
5946 var n0 = $e$.iterator; | 5950 \VAR{} $n0$ = $e$.iterator; |
5947 \WHILE{} (n0.moveNext()) \{ | 5951 \WHILE{} ($n0$.moveNext()) \{ |
5948 $finalConstVarOrType?$ id = n0.current; | 5952 $D$ $id$ = $n0$.current; |
5949 $s$ | 5953 $s$ |
5950 \} | 5954 \} |
5951 \end{dartCode} | 5955 \end{dartCode} |
5952 where \code{n0} is an identifier that does not occur anywhere in the program, ex
cept that for purposes of static typechecking, it is checked under the assumptio
n that $n0$ is declared to be of type $T$, where $T$ is the static type of $e.it
erator$. | 5956 |
| 5957 For purposes of static typechecking, |
| 5958 this code is checked under the assumption that $n0$ is declared to be of type $T
$, |
| 5959 where $T$ is the static type of \code{$e$.iterator}. |
| 5960 |
| 5961 \commentary{ |
| 5962 It follows that it is a static warning if $D$ is empty and $id$ is a final varia
ble, |
| 5963 and a dynamic error will then occur if the body is executed. |
| 5964 } |
5953 | 5965 |
5954 \subsubsection{Asynchronous For-in} | 5966 \subsubsection{Asynchronous For-in} |
5955 \LMLabel{asynchronousFor-in} | 5967 \LMLabel{asynchronousFor-in} |
5956 | 5968 |
5957 \LMHash{} | 5969 \LMHash{} |
5958 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. | 5970 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. |
5959 | 5971 |
5960 \LMHash{} | 5972 \LMHash{} |
5961 Execution of a for-in statement, $f$, of the form \code{\AWAIT{} \FOR{} (finalCo
nstVarOrType? $id$ \IN{} $e$) $s$} proceeds as follows: | 5973 Let $D$ be derived from \code{finalConstVarOrType?}. |
| 5974 Execution of a for-in statement, $f$, of the form |
| 5975 \code{\AWAIT{} \FOR{} ($D$ $id$ \IN{} $e$) $s$} |
| 5976 proceeds as follows: |
5962 | 5977 |
5963 \LMHash{} | 5978 \LMHash{} |
5964 The expression $e$ is evaluated to an object $o$. | 5979 The expression $e$ is evaluated to an object $o$. |
5965 It is a dynamic error if $o$ is not an instance of a class that implements \code
{Stream}. | 5980 It is a dynamic error if $o$ is not an instance of a class that implements \code
{Stream}. |
| 5981 It is a static warning if $D$ is empty and $id$ is a final variable, |
| 5982 and it is then a dynamic error if the body is executed. |
5966 | 5983 |
5967 \LMHash{} | 5984 \LMHash{} |
5968 The stream associated with the innermost enclosing asynchronous for loop, if any
, is paused. | 5985 The stream associated with the innermost enclosing asynchronous for loop, if any
, is paused. |
5969 The stream $o$ is listened to, producing a stream subscription $u$, | 5986 The stream $o$ is listened to, producing a stream subscription $u$, |
5970 and execution of the asynchronous for-in loop is suspended | 5987 and execution of the asynchronous for-in loop is suspended |
5971 until a stream event is available. | 5988 until a stream event is available. |
5972 \commentary{ | 5989 \commentary{ |
5973 This allows other asynchronous events to execute while this loop is waiting for
stream events. | 5990 This allows other asynchronous events to execute while this loop is waiting for
stream events. |
5974 } | 5991 } |
5975 | 5992 |
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8233 | 8250 |
8234 The invariant that each normative paragraph is associated with a line | 8251 The invariant that each normative paragraph is associated with a line |
8235 containing the text \LMHash{} should be maintained. Extra occurrences | 8252 containing the text \LMHash{} should be maintained. Extra occurrences |
8236 of \LMHash{} can be added if needed, e.g., in order to make | 8253 of \LMHash{} can be added if needed, e.g., in order to make |
8237 individual \item{}s in itemized lists addressable. Each \LM.. command | 8254 individual \item{}s in itemized lists addressable. Each \LM.. command |
8238 must occur on a separate line. \LMHash{} must occur immediately | 8255 must occur on a separate line. \LMHash{} must occur immediately |
8239 before the associated paragraph, and \LMLabel must occur immediately | 8256 before the associated paragraph, and \LMLabel must occur immediately |
8240 after the associated \section{}, \subsection{} etc. | 8257 after the associated \section{}, \subsection{} etc. |
8241 | 8258 |
8242 ---------------------------------------------------------------------- | 8259 ---------------------------------------------------------------------- |
OLD | NEW |