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 11 matching lines...) Expand all Loading... |
22 % 1.15 | 22 % 1.15 |
23 % - Change how language specification describes control flow. | 23 % - Change how language specification describes control flow. |
24 % - Object initialization now specifies initialization order correctly. | 24 % - Object initialization now specifies initialization order correctly. |
25 % - Specifies that leaving an await-for loop must wait for the subscription | 25 % - Specifies that leaving an await-for loop must wait for the subscription |
26 % to be canceled. | 26 % to be canceled. |
27 % - An await-for loop only pauses the subscription if it does something async. | 27 % - An await-for loop only pauses the subscription if it does something async. |
28 % - Assert statements allows a "message" operand and a trailing comma. | 28 % - Assert statements allows a "message" operand and a trailing comma. |
29 % - The Null type is now considered a subtype of all types in most cases. | 29 % - The Null type is now considered a subtype of all types in most cases. |
30 % - Specify what NEWLINE means in multiline strings. | 30 % - Specify what NEWLINE means in multiline strings. |
31 % - Specified the FutureOf type. | 31 % - Specified the FutureOf type. |
| 32 % - Asserts can occur in initializer lists. |
32 % | 33 % |
33 % 1.14 | 34 % 1.14 |
34 % - The call "C()" where "C" is a class name, is a now compile-time error. | 35 % - The call "C()" where "C" is a class name, is a now compile-time error. |
35 % - Changed description of rewrites that depended on a function literal. | 36 % - Changed description of rewrites that depended on a function literal. |
36 % In many cases, the rewrite wasn't safe for asynchronous code. | 37 % In many cases, the rewrite wasn't safe for asynchronous code. |
37 % - Removed generalized tear-offs. | 38 % - Removed generalized tear-offs. |
38 % - Allow "rethrow" to also end a switch case. Allow braces around switch cases. | 39 % - Allow "rethrow" to also end a switch case. Allow braces around switch cases. |
39 % - Allow using '=' as default-value separator for named parameters. | 40 % - Allow using '=' as default-value separator for named parameters. |
40 % - Make it a compile-time error if a library includes the same part twice. | 41 % - Make it a compile-time error if a library includes the same part twice. |
41 % - Now more specific about the return types of sync*/async/async* functions | 42 % - Now more specific about the return types of sync*/async/async* functions |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 \LMHash{} | 1398 \LMHash{} |
1398 An initializer list begins with a colon, and consists of a comma-separated list
of individual {\em initializers}. There are two kinds of initializers. | 1399 An initializer list begins with a colon, and consists of a comma-separated list
of individual {\em initializers}. There are two kinds of initializers. |
1399 \begin{itemize} | 1400 \begin{itemize} |
1400 \item A {\em superinitializer} identifies a {\em superconstructor} - that is, a
specific constructor of the superclass. Execution of the superinitializer cause
s the initializer list of the superconstructor to be executed. | 1401 \item A {\em superinitializer} identifies a {\em superconstructor} - that is, a
specific constructor of the superclass. Execution of the superinitializer cause
s the initializer list of the superconstructor to be executed. |
1401 | 1402 |
1402 \item An {\em instance variable initializer} assigns a value to an individual in
stance variable. | 1403 \item An {\em instance variable initializer} assigns a value to an individual in
stance variable. |
1403 \end{itemize} | 1404 \end{itemize} |
1404 | 1405 |
1405 \begin{grammar} | 1406 \begin{grammar} |
1406 {\bf initializers:} | 1407 {\bf initializers:} |
1407 `{\escapegrammar :}' superCallOrFieldInitializer (`,' superCallOrFieldInit
ializer)* | 1408 `{\escapegrammar :}' initializerListEntry (`,' initializerListEntry)* |
1408 . | 1409 . |
1409 | 1410 |
1410 | 1411 |
1411 {\bf superCallOrFieldInitializer:}\SUPER{} arguments; | 1412 {\bf initializerListEntry:}\SUPER{} arguments; |
1412 \SUPER{} `{\escapegrammar .}' identifier arguments; | 1413 \SUPER{} `{\escapegrammar .}' identifier arguments; |
1413 fieldInitializer | 1414 fieldInitializer; |
| 1415 assertion |
1414 . | 1416 . |
1415 | 1417 |
1416 {\bf fieldInitializer:} | 1418 {\bf fieldInitializer:} |
1417 (\THIS{} `{\escapegrammar .}')? identifier `=' conditionalExpression casca
deSection* | 1419 (\THIS{} `{\escapegrammar .}')? identifier `=' conditionalExpression casca
deSection* |
1418 . | 1420 . |
1419 | 1421 |
1420 \end{grammar} | 1422 \end{grammar} |
1421 | 1423 |
1422 \LMHash{} | 1424 \LMHash{} |
1423 Let $k$ be a generative constructor. | 1425 Let $k$ be a generative constructor. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 | 1515 |
1514 \LMHash{} | 1516 \LMHash{} |
1515 First, the expression $e$ is evaluated to an object $o$. | 1517 First, the expression $e$ is evaluated to an object $o$. |
1516 Then, the instance variable $v$ of $i$ is bound to $o$. | 1518 Then, the instance variable $v$ of $i$ is bound to $o$. |
1517 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$. | 1519 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$. |
1518 | 1520 |
1519 \LMHash{} | 1521 \LMHash{} |
1520 An initializer of the form \code{$v$ = $e$} is equivalent to an initializer of t
he form \code{\THIS{}.$v$ = $e$}. | 1522 An initializer of the form \code{$v$ = $e$} is equivalent to an initializer of t
he form \code{\THIS{}.$v$ = $e$}. |
1521 | 1523 |
1522 \LMHash{} | 1524 \LMHash{} |
| 1525 Execution of an initializer that is an assertion proceeds by executing the asser
tion (\ref{assert}). |
| 1526 |
| 1527 \LMHash{} |
1523 Execution of a superinitializer of the form | 1528 Execution of a superinitializer of the form |
1524 | 1529 |
1525 \SUPER{}$(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$ | 1530 \SUPER{}$(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$ |
1526 | 1531 |
1527 (respectively \SUPER{}$.id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}:
a_{n+k})$ | 1532 (respectively \SUPER{}$.id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}:
a_{n+k})$ |
1528 | 1533 |
1529 proceeds as follows: | 1534 proceeds as follows: |
1530 | 1535 |
1531 \LMHash{} | 1536 \LMHash{} |
1532 First, the argument list $(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}:
a_{n+k})$ is evaluated. | 1537 First, the argument list $(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}:
a_{n+k})$ is evaluated. |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 \item An expression of the form \code{$e_1 ?? e_2$} where $e_1$ and $e_2$ are co
nstant expressions. | 2621 \item An expression of the form \code{$e_1 ?? e_2$} where $e_1$ and $e_2$ are co
nstant expressions. |
2617 \item An expression of the form \code{$e$.length} where $e$ is a constant expres
sion that evaluates to a string value. | 2622 \item An expression of the form \code{$e$.length} where $e$ is a constant expres
sion that evaluates to a string value. |
2618 \end{itemize} | 2623 \end{itemize} |
2619 | 2624 |
2620 % null in all the expressions | 2625 % null in all the expressions |
2621 | 2626 |
2622 % designed so constants do not depend on check diode being on or not. | 2627 % designed so constants do not depend on check diode being on or not. |
2623 | 2628 |
2624 \LMHash{} | 2629 \LMHash{} |
2625 It is a compile-time error if an expression is required to be a constant express
ion but its evaluation would throw an exception. | 2630 It is a compile-time error if an expression is required to be a constant express
ion but its evaluation would throw an exception. |
| 2631 It is a compile-time error if an assertion is part of a compile-time constant co
nstructor invocation and the assertion would throw an exception. |
2626 | 2632 |
2627 % so, checked mode? analyzers? editor/development compilers? | 2633 % so, checked mode? analyzers? editor/development compilers? |
2628 \commentary{ | 2634 \commentary{ |
2629 Note that there is no requirement that every constant expression evaluate correc
tly. Only when a constant expression is required (e.g., to initialize a constant
variable, or as a default value of a formal parameter, or as metadata) do we in
sist that a constant expression actually be evaluated successfully at compile ti
me. | 2635 Note that there is no requirement that every constant expression evaluate correc
tly. Only when a constant expression is required (e.g., to initialize a constant
variable, or as a default value of a formal parameter, or as metadata) do we in
sist that a constant expression actually be evaluated successfully at compile ti
me. |
2630 | 2636 |
2631 The above is not dependent on program control-flow. The mere presence of a requi
red compile time constant whose evaluation would fail within a program is an err
or. This also holds recursively: since compound constants are composed out of c
onstants, if any subpart of a constant would throw an exception when evaluated,
that is an error. | 2637 The above is not dependent on program control-flow. The mere presence of a requi
red compile time constant whose evaluation would fail within a program is an err
or. This also holds recursively: since compound constants are composed out of c
onstants, if any subpart of a constant would throw an exception when evaluated,
that is an error. |
2632 | 2638 |
2633 On the other hand, since implementations are free to compile code late, some com
pile-time errors may manifest quite late. | 2639 On the other hand, since implementations are free to compile code late, some com
pile-time errors may manifest quite late. |
2634 } | 2640 } |
2635 | 2641 |
(...skipping 4096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6732 | 6738 |
6733 | 6739 |
6734 \subsection{ Assert} | 6740 \subsection{ Assert} |
6735 \LMLabel{assert} | 6741 \LMLabel{assert} |
6736 | 6742 |
6737 \LMHash{} | 6743 \LMHash{} |
6738 An {\em assert statement} is used to disrupt normal execution if a given boolean
condition does not hold. | 6744 An {\em assert statement} is used to disrupt normal execution if a given boolean
condition does not hold. |
6739 | 6745 |
6740 \begin{grammar} | 6746 \begin{grammar} |
6741 {\bf assertStatement:} | 6747 {\bf assertStatement:} |
6742 assert `(' expression ( `,' expression )? `,'? `)' `{\escapegrammar ;}' | 6748 assertion `{\escapegrammar ;}' |
6743 . | 6749 . |
| 6750 {\bf assertion:} |
| 6751 \ASSERT{} `(' expression ( `,' expression )? `,'? `)' |
| 6752 . |
6744 \end{grammar} | 6753 \end{grammar} |
6745 | 6754 |
6746 \LMHash{} | 6755 \LMHash{} |
6747 The grammar allows a trailing comma before the closing parenthesis, | 6756 The grammar allows a trailing comma before the closing parenthesis, |
6748 similarly to an argument list. That comma, if present, has no effect. | 6757 similarly to an argument list. That comma, if present, has no effect. |
6749 An assert statement with a trailing comme is equivalent to one with that | 6758 An assertion with a trailing comme is equivalent to one with that |
6750 comma removed. | 6759 comma removed. |
6751 | 6760 |
6752 \LMHash{} | 6761 \LMHash{} |
6753 An assert statement on the form \code{\ASSERT($e$);)} is equivalent to a statmen
t on the form \code{\ASSERT($e$, null);}. | 6762 An assertion on the form \code{\ASSERT($e$))} is equivalent to an assertion |
| 6763 on the form \code{\ASSERT($e$, null)}. |
6754 | 6764 |
6755 \LMHash{} | 6765 \LMHash{} |
6756 The assert statement has no effect in production mode. In checked mode, executio
n of an assert statement \code{\ASSERT{}($c$, $e$);} proceeds as follows: | 6766 Execution of an assert statement executes the assertion as described below |
| 6767 and completes in the same way as the assertion. |
6757 | 6768 |
6758 \LMHash{} | 6769 \LMHash{} |
6759 The expression $c$ is evaluated to an object $o$. If the class of $o$ is a subty
pe of \code{Function} then let $r$ be the result of invoking $o$ with no argumen
ts. Otherwise, let $r$ be $o$. | 6770 In production mode the assertion has no effect |
| 6771 and its execution immediately completes normally (\ref{completion}). |
| 6772 In checked mode, |
| 6773 execution of an assertion \code{\ASSERT{}($c$, $e$)} proceeds as follows: |
| 6774 |
| 6775 \LMHash{} |
| 6776 The expression $c$ is evaluated to an object $o$. |
| 6777 If the class of $o$ is not a subtype of \code{Function} then |
| 6778 let $r$ be $o$. |
| 6779 Otherwise, |
| 6780 if the assertion occurs in the initializer list of a \CONST{} constructor, |
| 6781 then we say that the assertion failed, |
| 6782 otherwise let $r$ be the result of invoking $o$ with no arguments. |
6760 It is a dynamic type error if $o$ is not of type \code{bool} or of type \code{Fu
nction}, or if $r$ is not of type \code{bool}. | 6783 It is a dynamic type error if $o$ is not of type \code{bool} or of type \code{Fu
nction}, or if $r$ is not of type \code{bool}. |
6761 If $r$ is \FALSE{}, we say that the assertion failed. | 6784 If $r$ is \FALSE{}, we say that the assertion failed. |
6762 If $r$ is \TRUE{}, we say that the assertion succeeded. | 6785 If $r$ is \TRUE{}, we say that the assertion succeeded. |
6763 If the assertion succeeded, execution of the assert statement completes normally
(\ref{completion}). | 6786 If the assertion succeeded, execution of the assert statement completes normally
(\ref{completion}). |
6764 If the assertion failed, $e$ is evaluated to an object $m$. | 6787 If the assertion failed, $e$ is evaluated to an object $m$. |
6765 Then the execution of the assert statement throws (\ref{completion}) an \code{As
sertionError} containing $m$ and with a stack trace corresponding to the current
execution state at the \ASSERT{} statement. | 6788 Then the execution of the assert statement throws (\ref{completion}) an \code{As
sertionError} containing $m$ and with a stack trace corresponding to the current
execution state at the \ASSERT{} statement. |
6766 | 6789 |
6767 \LMHash{} | 6790 \LMHash{} |
6768 It is a static type warning if the type of $e$ may not be assigned to either \c
ode{bool} or $() \rightarrow$ \code{bool}. | 6791 It is a static type warning if the type of $e$ may not be assigned to either |
| 6792 \code{bool} or $() \rightarrow$ \code{bool}. |
| 6793 If the assertion occurs in a \CONST{} constructor initializer list, it is a stat
ic type warning if the type of $e$ may not be assigned to \code{bool}. |
6769 | 6794 |
6770 \rationale{Why is this a statement, not a built in function call? Because it is
handled magically so it has no effect and no overhead in production mode. Also,
in the absence of final methods. one could not prevent it being overridden (thou
gh there is no real harm in that). It cannot be viewed as a function call that
is being optimized away because the argument might have side effects. | 6795 \rationale{Why is this a statement, not a built in function call? Because it is
handled magically so it has no effect and no overhead in production mode. Also,
in the absence of final methods. one could not prevent it being overridden (thou
gh there is no real harm in that). It cannot be viewed as a function call that
is being optimized away because the argument might have side effects. |
6771 } | 6796 } |
6772 | 6797 |
6773 %If a lexically visible declaration named \code{assert} is in scope, an assert s
tatement | 6798 %If a lexically visible declaration named \code{assert} is in scope, an assert s
tatement |
6774 %\code{\ASSERT{} (e); } | 6799 %\code{\ASSERT{} (e); } |
6775 %is interpreted as an expression statement \code{(assert(e));} . | 6800 %is interpreted as an expression statement \code{(assert(e));} . |
6776 | 6801 |
6777 %\rationale{ | 6802 %\rationale{ |
6778 %Since \ASSERT{} is a built-in identifier, one might define a function or method
with this name. | 6803 %Since \ASSERT{} is a built-in identifier, one might define a function or method
with this name. |
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8213 | 8238 |
8214 The invariant that each normative paragraph is associated with a line | 8239 The invariant that each normative paragraph is associated with a line |
8215 containing the text \LMHash{} should be maintained. Extra occurrences | 8240 containing the text \LMHash{} should be maintained. Extra occurrences |
8216 of \LMHash{} can be added if needed, e.g., in order to make | 8241 of \LMHash{} can be added if needed, e.g., in order to make |
8217 individual \item{}s in itemized lists addressable. Each \LM.. command | 8242 individual \item{}s in itemized lists addressable. Each \LM.. command |
8218 must occur on a separate line. \LMHash{} must occur immediately | 8243 must occur on a separate line. \LMHash{} must occur immediately |
8219 before the associated paragraph, and \LMLabel must occur immediately | 8244 before the associated paragraph, and \LMLabel must occur immediately |
8220 after the associated \section{}, \subsection{} etc. | 8245 after the associated \section{}, \subsection{} etc. |
8221 | 8246 |
8222 ---------------------------------------------------------------------- | 8247 ---------------------------------------------------------------------- |
OLD | NEW |