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

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

Issue 2143363002: Spec: Allow any expression in assert statements. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 \newcommand{\code}[1]{{\sf #1}} 8 \newcommand{\code}[1]{{\sf #1}}
9 \title{Dart Programming Language Specification \\ 9 \title{Dart Programming Language Specification \\
10 {4th edition draft}\\ 10 {4th edition draft}\\
(...skipping 6461 matching lines...) Expand 10 before | Expand all | Expand 10 after
6472 6472
6473 6473
6474 \subsection{ Assert} 6474 \subsection{ Assert}
6475 \LMLabel{assert} 6475 \LMLabel{assert}
6476 6476
6477 \LMHash{} 6477 \LMHash{}
6478 An {\em assert statement} is used to disrupt normal execution if a given boolean condition does not hold. 6478 An {\em assert statement} is used to disrupt normal execution if a given boolean condition does not hold.
6479 6479
6480 \begin{grammar} 6480 \begin{grammar}
6481 {\bf assertStatement:} 6481 {\bf assertStatement:}
6482 assert `(' conditionalExpression `)' `{\escapegrammar ;}' 6482 assert `(' expression `)' `{\escapegrammar ;}'
6483 . 6483 .
6484 \end{grammar} 6484 \end{grammar}
6485 6485
6486 \LMHash{} 6486 \LMHash{}
6487 The assert statement has no effect in production mode. In checked mode, executio n of an assert statement \code{\ASSERT{}($e$);} proceeds as follows: 6487 The assert statement has no effect in production mode. In checked mode, executio n of an assert statement \code{\ASSERT{}($e$);} proceeds as follows:
6488 6488
6489 \LMHash{} 6489 \LMHash{}
6490 The conditional expression $e$ is evaluated to an object $o$. If the class of $o $ is a subtype of \code{Function} then let $r$ be the result of invoking $o$ wit h no arguments. Otherwise, let $r$ be $o$. 6490 The expression $e$ 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$.
6491 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}. If $r$ is \FALSE{}, we say that the assertion failed. If $r$ is \TRUE{}, we say that the assertion succeeded. If the assertion succeeded, execution of the assert statement is complete. If the assertion failed, an \code{AssertionError} is thrown. 6491 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}. If $r$ is \FALSE{}, we say that the assertion failed. If $r$ is \TRUE{}, we say that the assertion succeeded. If the assertion succeeded, execution of the assert statement is complete. If the assertion failed, an \code{AssertionError} is thrown.
6492 6492
6493 %\Q{Might be cleaner to define it as \code{if (!$e$) \{\THROW{} \NEW{} Assertion Error();\}} (in checked mode only). 6493 %\Q{Might be cleaner to define it as \code{if (!$e$) \{\THROW{} \NEW{} Assertion Error();\}} (in checked mode only).
6494 %What about an error message as part of the assert?} 6494 %What about an error message as part of the assert?}
6495 6495
6496 \LMHash{} 6496 \LMHash{}
6497 It is a static type warning if the type of $e$ may not be assigned to either \ code{bool} or $() \rightarrow$ \code{bool}. 6497 It is a static type warning if the type of $e$ may not be assigned to either \ code{bool} or $() \rightarrow$ \code{bool}.
6498 6498
6499 \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. 6499 \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.
6500 } 6500 }
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
7889 7889
7890 The invariant that each normative paragraph is associated with a line 7890 The invariant that each normative paragraph is associated with a line
7891 containing the text \LMHash{} should be maintained. Extra occurrences 7891 containing the text \LMHash{} should be maintained. Extra occurrences
7892 of \LMHash{} can be added if needed, e.g., in order to make 7892 of \LMHash{} can be added if needed, e.g., in order to make
7893 individual \item{}s in itemized lists addressable. Each \LM.. command 7893 individual \item{}s in itemized lists addressable. Each \LM.. command
7894 must occur on a separate line. \LMHash{} must occur immediately 7894 must occur on a separate line. \LMHash{} must occur immediately
7895 before the associated paragraph, and \LMLabel must occur immediately 7895 before the associated paragraph, and \LMLabel must occur immediately
7896 after the associated \section{}, \subsection{} etc. 7896 after the associated \section{}, \subsection{} etc.
7897 7897
7898 ---------------------------------------------------------------------- 7898 ----------------------------------------------------------------------
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