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

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

Issue 2530083002: Add message to assert in specification. (Closed)
Patch Set: Created 4 years 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 6575 matching lines...) Expand 10 before | Expand all | Expand 10 after
6586 6586
6587 6587
6588 \subsection{ Assert} 6588 \subsection{ Assert}
6589 \LMLabel{assert} 6589 \LMLabel{assert}
6590 6590
6591 \LMHash{} 6591 \LMHash{}
6592 An {\em assert statement} is used to disrupt normal execution if a given boolean condition does not hold. 6592 An {\em assert statement} is used to disrupt normal execution if a given boolean condition does not hold.
6593 6593
6594 \begin{grammar} 6594 \begin{grammar}
6595 {\bf assertStatement:} 6595 {\bf assertStatement:}
6596 assert `(' expression `)' `{\escapegrammar ;}' 6596 assert `(' expression ( `,` expression )? `)' `{\escapegrammar ;}'
6597 . 6597 .
6598 \end{grammar} 6598 \end{grammar}
6599 6599
6600 \LMHash{} 6600 \LMHash{}
6601 The assert statement has no effect in production mode. In checked mode, executio n of an assert statement \code{\ASSERT{}($e$);} proceeds as follows: 6601 An assert statement on the form \code{\ASSERT($e$);)} is equivalent to a statmen t on the form \code{\ASSERT($e$, null);}.
6602 6602
6603 \LMHash{} 6603 \LMHash{}
6604 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$. 6604 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:
6605 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, the execution throws (\ref{completion}) an \code{AssertionErro r} with a stack trace corresponding to the current execution state at the \ASSER T{} statement.
6606 6605
6607 %\Q{Might be cleaner to define it as \code{if (!$e$) \{\THROW{} \NEW{} Assertion Error();\}} (in checked mode only). 6606 \LMHash{}
6608 %What about an error message as part of the assert?} 6607 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$.
6608 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}.
6609 If $r$ is \FALSE{}, we say that the assertion failed.
6610 If $r$ is \TRUE{}, we say that the assertion succeeded.
6611 If the assertion succeeded, execution of the assert statement completes normally (\ref{completion}).
6612 If the assertion failed, $e$ is evaluated to an object $m$.
6613 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.
6609 6614
6610 \LMHash{} 6615 \LMHash{}
6611 It is a static type warning if the type of $e$ may not be assigned to either \ code{bool} or $() \rightarrow$ \code{bool}. 6616 It is a static type warning if the type of $e$ may not be assigned to either \ code{bool} or $() \rightarrow$ \code{bool}.
6612 6617
6613 \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. 6618 \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.
6614 } 6619 }
6615 6620
6616 %If a lexically visible declaration named \code{assert} is in scope, an assert s tatement 6621 %If a lexically visible declaration named \code{assert} is in scope, an assert s tatement
6617 %\code{\ASSERT{} (e); } 6622 %\code{\ASSERT{} (e); }
6618 %is interpreted as an expression statement \code{(assert(e));} . 6623 %is interpreted as an expression statement \code{(assert(e));} .
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
8006 8011
8007 The invariant that each normative paragraph is associated with a line 8012 The invariant that each normative paragraph is associated with a line
8008 containing the text \LMHash{} should be maintained. Extra occurrences 8013 containing the text \LMHash{} should be maintained. Extra occurrences
8009 of \LMHash{} can be added if needed, e.g., in order to make 8014 of \LMHash{} can be added if needed, e.g., in order to make
8010 individual \item{}s in itemized lists addressable. Each \LM.. command 8015 individual \item{}s in itemized lists addressable. Each \LM.. command
8011 must occur on a separate line. \LMHash{} must occur immediately 8016 must occur on a separate line. \LMHash{} must occur immediately
8012 before the associated paragraph, and \LMLabel must occur immediately 8017 before the associated paragraph, and \LMLabel must occur immediately
8013 after the associated \section{}, \subsection{} etc. 8018 after the associated \section{}, \subsection{} etc.
8014 8019
8015 ---------------------------------------------------------------------- 8020 ----------------------------------------------------------------------
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