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

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

Issue 2974763002: Don't allow function values in assert tests. (Closed)
Patch Set: Address comments Created 3 years, 4 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 \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 1.15.0}} 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
23 % - Don't allow functions as assert test values.
24 %
22 % 1.15 25 % 1.15
23 % - Change how language specification describes control flow. 26 % - Change how language specification describes control flow.
24 % - Object initialization now specifies initialization order correctly. 27 % - Object initialization now specifies initialization order correctly.
25 % - Specifies that leaving an await-for loop must wait for the subscription 28 % - Specifies that leaving an await-for loop must wait for the subscription
26 % to be canceled. 29 % to be canceled.
27 % - An await-for loop only pauses the subscription if it does something async. 30 % - An await-for loop only pauses the subscription if it does something async.
28 % - Assert statements allows a "message" operand and a trailing comma. 31 % - 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. 32 % - The Null type is now considered a subtype of all types in most cases.
30 % - Specify what NEWLINE means in multiline strings. 33 % - Specify what NEWLINE means in multiline strings.
31 % - Specified the FutureOf type. 34 % - Specified the FutureOf type.
(...skipping 6718 matching lines...) Expand 10 before | Expand all | Expand 10 after
6750 assertion `{\escapegrammar ;}' 6753 assertion `{\escapegrammar ;}'
6751 . 6754 .
6752 {\bf assertion:} 6755 {\bf assertion:}
6753 \ASSERT{} `(' expression ( `,' expression )? `,'? `)' 6756 \ASSERT{} `(' expression ( `,' expression )? `,'? `)'
6754 . 6757 .
6755 \end{grammar} 6758 \end{grammar}
6756 6759
6757 \LMHash{} 6760 \LMHash{}
6758 The grammar allows a trailing comma before the closing parenthesis, 6761 The grammar allows a trailing comma before the closing parenthesis,
6759 similarly to an argument list. That comma, if present, has no effect. 6762 similarly to an argument list. That comma, if present, has no effect.
6760 An assertion with a trailing comme is equivalent to one with that 6763 An assertion with a trailing comma is equivalent to one with that
6761 comma removed. 6764 comma removed.
6762 6765
6763 \LMHash{} 6766 \LMHash{}
6764 An assertion on the form \code{\ASSERT($e$))} is equivalent to an assertion 6767 An assertion on the form \code{\ASSERT($e$))} is equivalent to an assertion on t he form \code{\ASSERT($e$, null)}.
Bob Nystrom 2017/08/14 21:22:43 "on" -> "of", in both places.
6765 on the form \code{\ASSERT($e$, null)}.
6766 6768
6767 \LMHash{} 6769 \LMHash{}
6768 Execution of an assert statement executes the assertion as described below 6770 Execution of an assert statement executes the assertion as described below
6769 and completes in the same way as the assertion. 6771 and completes in the same way as the assertion.
6770 6772
6771 \LMHash{} 6773 \LMHash{}
6772 In production mode the assertion has no effect 6774 In production mode an assertion has no effect
6773 and its execution immediately completes normally (\ref{completion}). 6775 and its execution immediately completes normally (\ref{completion}).
6774 In checked mode, 6776 In checked mode,
6775 execution of an assertion \code{\ASSERT{}($c$, $e$)} proceeds as follows: 6777 execution of an assertion \code{\ASSERT{}($c$, $e$)} proceeds as follows:
6776 6778
6777 \LMHash{} 6779 \LMHash{}
6778 The expression $c$ is evaluated to an object $o$. 6780 The expression $c$ is evaluated to an object $r$.
6779 If the class of $o$ is a subtype of \code{Function}
6780 and the assertion does not occur in the initializer list of a \CONST{} construct or,
6781 then let $r$ be the result of invoking $o$ with no arguments.
6782 Otherwise let $r$ be $o$.
6783 It is a dynamic type error if $r$ is not of type \code{bool}. 6781 It is a dynamic type error if $r$ is not of type \code{bool}.
6784 \commentary{Hence it is a compile-time error if that situation arises during eva luation of an assertion in a \CONST{} constructor invocation.} 6782 \commentary{Hence it is a compile-time error if that situation arises during eva luation of an assertion in a \CONST{} constructor invocation.}
6785 If $r$ is \TRUE{}, execution of the assert statement completes normally (\ref{co mpletion}). 6783 If $r$ is \TRUE{} then execution of the assert statement completes normally (\re f{completion}).
6786 Otherwise, $e$ is evaluated to an object $m$ 6784 Otherwise, $e$ is evaluated to an object $m$
6787 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. 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 assertion.
6788 6786
6789 \LMHash{} 6787 \LMHash{}
6790 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 \code{bool }.
6791 \code{bool} or $() \rightarrow$ \code{bool}.
6792 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}.
6793 6789
6794 \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. 6790 \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 i s being optimized away because the arguments might have side effects.
6795 } 6791 }
6796 6792
6797 %If a lexically visible declaration named \code{assert} is in scope, an assert s tatement 6793 %If a lexically visible declaration named \code{assert} is in scope, an assert s tatement
6798 %\code{\ASSERT{} (e); } 6794 %\code{\ASSERT{} (e); }
6799 %is interpreted as an expression statement \code{(assert(e));} . 6795 %is interpreted as an expression statement \code{(assert(e));} .
6800 6796
6801 %\rationale{ 6797 %\rationale{
6802 %Since \ASSERT{} is a built-in identifier, one might define a function or method with this name. 6798 %Since \ASSERT{} is a built-in identifier, one might define a function or method with this name.
6803 %It is impossible to distinguish as \ASSERT{} statement from a method invocation in such a situation. 6799 %It is impossible to distinguish as \ASSERT{} statement from a method invocation in such a situation.
6804 %One could choose to always interpret such code as an \ASSERT{} statement. Or we could choose to give priority to any lexically visible user defined function. The former can cause rather puzzling situations, e.g.,} 6800 %One could choose to always interpret such code as an \ASSERT{} statement. Or we could choose to give priority to any lexically visible user defined function. The former can cause rather puzzling situations, e.g.,}
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
8237 8233
8238 The invariant that each normative paragraph is associated with a line 8234 The invariant that each normative paragraph is associated with a line
8239 containing the text \LMHash{} should be maintained. Extra occurrences 8235 containing the text \LMHash{} should be maintained. Extra occurrences
8240 of \LMHash{} can be added if needed, e.g., in order to make 8236 of \LMHash{} can be added if needed, e.g., in order to make
8241 individual \item{}s in itemized lists addressable. Each \LM.. command 8237 individual \item{}s in itemized lists addressable. Each \LM.. command
8242 must occur on a separate line. \LMHash{} must occur immediately 8238 must occur on a separate line. \LMHash{} must occur immediately
8243 before the associated paragraph, and \LMLabel must occur immediately 8239 before the associated paragraph, and \LMLabel must occur immediately
8244 after the associated \section{}, \subsection{} etc. 8240 after the associated \section{}, \subsection{} etc.
8245 8241
8246 ---------------------------------------------------------------------- 8242 ----------------------------------------------------------------------
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