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 6719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6730 \end{itemize} | 6730 \end{itemize} |
6731 | 6731 |
6732 | 6732 |
6733 \LMHash{} | 6733 \LMHash{} |
6734 It is a compile-time error if a yield-each statement appears in a function that
is not a generator function. | 6734 It is a compile-time error if a yield-each statement appears in a function that
is not a generator function. |
6735 | 6735 |
6736 \LMHash{} | 6736 \LMHash{} |
6737 Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing funct
ion. It is a static type warning if $T$ may not be assigned to the declared ret
urn type of $f$. If $f$ is synchronous it is a static type warning if $T$ may
not be assigned to \code{Iterable}. If $f$ is asynchronous it is a static type
warning if $T$ may not be assigned to \code{Stream}. | 6737 Let $T$ be the static type of $e$ and let $f$ be the immediately enclosing funct
ion. It is a static type warning if $T$ may not be assigned to the declared ret
urn type of $f$. If $f$ is synchronous it is a static type warning if $T$ may
not be assigned to \code{Iterable}. If $f$ is asynchronous it is a static type
warning if $T$ may not be assigned to \code{Stream}. |
6738 | 6738 |
6739 | 6739 |
6740 \subsection{ Assert} | 6740 \subsection{Assert} |
6741 \LMLabel{assert} | 6741 \LMLabel{assert} |
6742 | 6742 |
6743 \LMHash{} | 6743 \LMHash{} |
6744 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. |
6745 | 6745 |
6746 \begin{grammar} | 6746 \begin{grammar} |
6747 {\bf assertStatement:} | 6747 {\bf assertStatement:} |
6748 assertion `{\escapegrammar ;}' | 6748 assertion `{\escapegrammar ;}' |
6749 . | 6749 . |
6750 {\bf assertion:} | 6750 {\bf assertion:} |
(...skipping 16 matching lines...) Expand all Loading... |
6767 and completes in the same way as the assertion. | 6767 and completes in the same way as the assertion. |
6768 | 6768 |
6769 \LMHash{} | 6769 \LMHash{} |
6770 In production mode the assertion has no effect | 6770 In production mode the assertion has no effect |
6771 and its execution immediately completes normally (\ref{completion}). | 6771 and its execution immediately completes normally (\ref{completion}). |
6772 In checked mode, | 6772 In checked mode, |
6773 execution of an assertion \code{\ASSERT{}($c$, $e$)} proceeds as follows: | 6773 execution of an assertion \code{\ASSERT{}($c$, $e$)} proceeds as follows: |
6774 | 6774 |
6775 \LMHash{} | 6775 \LMHash{} |
6776 The expression $c$ is evaluated to an object $o$. | 6776 The expression $c$ is evaluated to an object $o$. |
6777 If the class of $o$ is not a subtype of \code{Function} then | 6777 If the class of $o$ is a subtype of \code{Function} |
6778 let $r$ be $o$. | 6778 and the assertion does not occur in the initializer list of a \CONST{} construct
or, |
6779 Otherwise, | 6779 then let $r$ be the result of invoking $o$ with no arguments. |
6780 if the assertion occurs in the initializer list of a \CONST{} constructor, | 6780 Otherwise let $r$ be $o$. |
6781 then we say that the assertion failed, | 6781 It is a dynamic type error if $r$ is not of type \code{bool}. |
6782 otherwise let $r$ be the result of invoking $o$ with no arguments. | 6782 \commentary{Hence it is a compile-time error if that situation arises during eva
luation of an assertion in a \CONST{} constructor invocation.} |
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}. | 6783 If $r$ is \TRUE{}, execution of the assert statement completes normally (\ref{co
mpletion}). |
6784 If $r$ is \FALSE{}, we say that the assertion failed. | 6784 Otherwise, $e$ is evaluated to an object $m$ |
6785 If $r$ is \TRUE{}, we say that the assertion succeeded. | 6785 and then the execution of the assert statement throws (\ref{completion}) an \cod
e{AssertionError} containing $m$ and with a stack trace corresponding to the cur
rent execution state at the \ASSERT{} statement. |
6786 If the assertion succeeded, execution of the assert statement completes normally
(\ref{completion}). | |
6787 If the assertion failed, $e$ is evaluated to an object $m$. | |
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. | |
6789 | 6786 |
6790 \LMHash{} | 6787 \LMHash{} |
6791 It is a static type warning if the type of $e$ may not be assigned to either | 6788 It is a static type warning if the type of $e$ may not be assigned to either |
6792 \code{bool} or $() \rightarrow$ \code{bool}. | 6789 \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}. | 6790 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}. |
6794 | 6791 |
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. | 6792 \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. |
6796 } | 6793 } |
6797 | 6794 |
6798 %If a lexically visible declaration named \code{assert} is in scope, an assert s
tatement | 6795 %If a lexically visible declaration named \code{assert} is in scope, an assert s
tatement |
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8238 | 8235 |
8239 The invariant that each normative paragraph is associated with a line | 8236 The invariant that each normative paragraph is associated with a line |
8240 containing the text \LMHash{} should be maintained. Extra occurrences | 8237 containing the text \LMHash{} should be maintained. Extra occurrences |
8241 of \LMHash{} can be added if needed, e.g., in order to make | 8238 of \LMHash{} can be added if needed, e.g., in order to make |
8242 individual \item{}s in itemized lists addressable. Each \LM.. command | 8239 individual \item{}s in itemized lists addressable. Each \LM.. command |
8243 must occur on a separate line. \LMHash{} must occur immediately | 8240 must occur on a separate line. \LMHash{} must occur immediately |
8244 before the associated paragraph, and \LMLabel must occur immediately | 8241 before the associated paragraph, and \LMLabel must occur immediately |
8245 after the associated \section{}, \subsection{} etc. | 8242 after the associated \section{}, \subsection{} etc. |
8246 | 8243 |
8247 ---------------------------------------------------------------------- | 8244 ---------------------------------------------------------------------- |
OLD | NEW |