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 \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 5955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5966 | 5966 |
5967 | 5967 |
5968 \commentary{ | 5968 \commentary{ |
5969 In other words, there is no implicit fall-through between non-empty cases. The l
ast case in a switch (default or otherwise) can `fall-through' to the end of the
statement. | 5969 In other words, there is no implicit fall-through between non-empty cases. The l
ast case in a switch (default or otherwise) can `fall-through' to the end of the
statement. |
5970 } | 5970 } |
5971 | 5971 |
5972 \LMHash{} | 5972 \LMHash{} |
5973 It is a static warning if the type of $e$ may not be assigned to the type of $e_
k$. | 5973 It is a static warning if the type of $e$ may not be assigned to the type of $e_
k$. |
5974 Let $s$ be the last statement of the statement sequence $s_k$. | 5974 Let $s$ be the last statement of the statement sequence $s_k$. |
5975 If $s$ is a non-empty block statement, let $s$ instead be the last statment of t
he block statement. | 5975 If $s$ is a non-empty block statement, let $s$ instead be the last statment of t
he block statement. |
5976 It is a static warning $s$ is not a \BREAK{}, \CONTINUE{}, \REHTROW{} or \RETURN
{} statement or an expression statment where the expression is a \THROW{} expres
sion. | 5976 It is a static warning $s$ is not a \BREAK{}, \CONTINUE{}, \RETHROW{} or \RETURN
{} statement or an expression statment where the expression is a \THROW{} expres
sion. |
5977 | 5977 |
5978 \rationale{ | 5978 \rationale{ |
5979 The behavior of switch cases intentionally differs from the C tradition. Implic
it fall through is a known cause of programming errors and therefore disallowed.
Why not simply break the flow implicitly at the end of every case, rather than
requiring explicit code to do so? This would indeed be cleaner. It would also
be cleaner to insist that each case have a single (possibly compound) statement
. We have chosen not to do so in order to facilitate porting of switch statemen
ts from other languages. Implicitly breaking the control flow at the end of a c
ase would silently alter the meaning of ported code that relied on fall-through,
potentially forcing the programmer to deal with subtle bugs. Our design ensures
that the difference is immediately brought to the coder's attention. The progr
ammer will be notified at compile-time if they forget to end a case with a state
ment that terminates the straight-line control flow. We could make this warning
a compile-time error, but refrain from doing so because do not wish to force the
programmer to deal with this issue immediately while porting code. If develope
rs ignore the warning and run their code, a run time error will prevent the prog
ram from misbehaving in hard-to-debug ways (at least with respect to this issue)
. | 5979 The behavior of switch cases intentionally differs from the C tradition. Implic
it fall through is a known cause of programming errors and therefore disallowed.
Why not simply break the flow implicitly at the end of every case, rather than
requiring explicit code to do so? This would indeed be cleaner. It would also
be cleaner to insist that each case have a single (possibly compound) statement
. We have chosen not to do so in order to facilitate porting of switch statemen
ts from other languages. Implicitly breaking the control flow at the end of a c
ase would silently alter the meaning of ported code that relied on fall-through,
potentially forcing the programmer to deal with subtle bugs. Our design ensures
that the difference is immediately brought to the coder's attention. The progr
ammer will be notified at compile-time if they forget to end a case with a state
ment that terminates the straight-line control flow. We could make this warning
a compile-time error, but refrain from doing so because do not wish to force the
programmer to deal with this issue immediately while porting code. If develope
rs ignore the warning and run their code, a run time error will prevent the prog
ram from misbehaving in hard-to-debug ways (at least with respect to this issue)
. |
5980 | 5980 |
5981 The sophistication of the analysis of fall-through is another issue. For now, we
have opted for a very straightforward syntactic requirement. There are obviousl
y situations where code does not fall through, and yet does not conform to these
simple rules, e.g.: | 5981 The sophistication of the analysis of fall-through is another issue. For now, we
have opted for a very straightforward syntactic requirement. There are obviousl
y situations where code does not fall through, and yet does not conform to these
simple rules, e.g.: |
5982 } | 5982 } |
5983 | 5983 |
5984 \begin{dartCode} | 5984 \begin{dartCode} |
5985 \SWITCH{} (x) \{ | 5985 \SWITCH{} (x) \{ |
5986 \CASE{} 1: \TRY{} \{ $\ldots$ \RETURN{};\} \FINALLY{} \{ $\ldots$ \RETURN{};\} | 5986 \CASE{} 1: \TRY{} \{ $\ldots$ \RETURN{};\} \FINALLY{} \{ $\ldots$ \RETURN{};\} |
(...skipping 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7915 | 7915 |
7916 The invariant that each normative paragraph is associated with a line | 7916 The invariant that each normative paragraph is associated with a line |
7917 containing the text \LMHash{} should be maintained. Extra occurrences | 7917 containing the text \LMHash{} should be maintained. Extra occurrences |
7918 of \LMHash{} can be added if needed, e.g., in order to make | 7918 of \LMHash{} can be added if needed, e.g., in order to make |
7919 individual \item{}s in itemized lists addressable. Each \LM.. command | 7919 individual \item{}s in itemized lists addressable. Each \LM.. command |
7920 must occur on a separate line. \LMHash{} must occur immediately | 7920 must occur on a separate line. \LMHash{} must occur immediately |
7921 before the associated paragraph, and \LMLabel must occur immediately | 7921 before the associated paragraph, and \LMLabel must occur immediately |
7922 after the associated \section{}, \subsection{} etc. | 7922 after the associated \section{}, \subsection{} etc. |
7923 | 7923 |
7924 ---------------------------------------------------------------------- | 7924 ---------------------------------------------------------------------- |
OLD | NEW |