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

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

Issue 26650006: Slight rewording of compile-time errors for switch cases, for clarity. No semantic change. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« 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{dart} 3 \usepackage{dart}
4 \usepackage{bnf} 4 \usepackage{bnf}
5 \usepackage{hyperref} 5 \usepackage{hyperref}
6 \newcommand{\code}[1]{{\sf #1}} 6 \newcommand{\code}[1]{{\sf #1}}
7 \title{Dart Programming Language Specification \\ 7 \title{Dart Programming Language Specification \\
8 {\large Draft Version 0.61}} 8 {\large Draft Version 0.61}}
9 \author{The Dart Team} 9 \author{The Dart Team}
10 \begin{document} 10 \begin{document}
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 Metadata consists of a series of annotations, each of which begin with the chara cter @, followed by a constant expression that starts with an identifier. It is a compile time error if the expression is not one of the following: 2354 Metadata consists of a series of annotations, each of which begin with the chara cter @, followed by a constant expression that starts with an identifier. It is a compile time error if the expression is not one of the following:
2355 \begin{itemize} 2355 \begin{itemize}
2356 \item A reference to a compile-time constant variable. 2356 \item A reference to a compile-time constant variable.
2357 \item The name of a class. 2357 \item The name of a class.
2358 \item A call to a constant constructor. 2358 \item A call to a constant constructor.
2359 \end{itemize} 2359 \end{itemize}
2360 2360
2361 Metadata is associated with the abstract syntax tree of the program construct $p $ that immediately follows the metadata, assuming $p$ is not itself metadata or a comment. Metadata can be retrieved at runtime via a reflective call, provided the annotated program construct $p$ is accessible via reflection. 2361 Metadata is associated with the abstract syntax tree of the program construct $p $ that immediately follows the metadata, assuming $p$ is not itself metadata or a comment. Metadata can be retrieved at runtime via a reflective call, provided the annotated program construct $p$ is accessible via reflection.
2362 2362
2363 \commentary{ 2363 \commentary{
2364 Reflective access to metadata is not yet implemented as of the M4 release.
2365
2366 Obviously, metadata can also be retrieved statically by parsing the program and evaluating the constants via a suitable interpreter. In fact many if not most us es of metadata are entirely static. 2364 Obviously, metadata can also be retrieved statically by parsing the program and evaluating the constants via a suitable interpreter. In fact many if not most us es of metadata are entirely static.
2367 } 2365 }
2368 2366
2369 \rationale{ 2367 \rationale{
2370 It is important that no runtime overhead be incurred by the introduction of meta data that is not actually used. Because metadata only involves constants, the ti me at which it is computed is irrelevant so that implementations may skip the me tadata during ordinary parsing and execution and evaluate it lazily. 2368 It is important that no runtime overhead be incurred by the introduction of meta data that is not actually used. Because metadata only involves constants, the ti me at which it is computed is irrelevant so that implementations may skip the me tadata during ordinary parsing and execution and evaluate it lazily.
2371 } 2369 }
2372 2370
2373 \commentary{ 2371 \commentary{
2374 It is possible to associate metadata with constructs that may not be accessible via reflection, such as local variables (though it is conceivable that in the fu ture, richer reflective libraries might provide access to these as well). This is not as useless as it might seem. As noted above, the data can be retrieved st atically if source code is available. 2372 It is possible to associate metadata with constructs that may not be accessible via reflection, such as local variables (though it is conceivable that in the fu ture, richer reflective libraries might provide access to these as well). This is not as useless as it might seem. As noted above, the data can be retrieved st atically if source code is available.
2375 } 2373 }
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after
4763 4761
4764 {\bf switchCase:} 4762 {\bf switchCase:}
4765 label* (\CASE{} expression `{\escapegrammar :}') statements 4763 label* (\CASE{} expression `{\escapegrammar :}') statements
4766 . 4764 .
4767 4765
4768 {\bf defaultCase:} 4766 {\bf defaultCase:}
4769 label* \DEFAULT{} `{\escapegrammar :}' statements 4767 label* \DEFAULT{} `{\escapegrammar :}' statements
4770 . 4768 .
4771 \end{grammar} 4769 \end{grammar}
4772 4770
4773 Given a switch statement of the form \code{\SWITCH{} ($e$) \{ \CASE{} $label_{1 1} \ldots label_{1j_1}$ $e_1: s_1 \ldots$ \CASE{} $label_{n1} \ldots label_{nj_ n}$ $e_n: s_n$ \DEFAULT{}: $s_{n+1}$ \}} or the form \code{\SWITCH{} ($e$) \{ \C ASE{} $label_{11} \ldots label_{1j_1}$ $e_1: s_1 \ldots$ \CASE{} $label_{n1} \l dots label_{nj_n}$ $e_n: s_n$ \}}, it is a compile-time error if the expressions $e_k$ are not compile-time constants for all $k \in 1..n$. It is a compile-ti me error if the values of the expressions $e_k$ are not all instances of the sam e class $C$ or of a class that implements \cd{int} or \cd{String}, for all $k \i n 1..n$. 4771 Given a switch statement of the form \code{\SWITCH{} ($e$) \{ \CASE{} $label_{1 1} \ldots label_{1j_1}$ $e_1: s_1 \ldots$ \CASE{} $label_{n1} \ldots label_{nj_ n}$ $e_n: s_n$ \DEFAULT{}: $s_{n+1}$ \}} or the form \code{\SWITCH{} ($e$) \{ \C ASE{} $label_{11} \ldots label_{1j_1}$ $e_1: s_1 \ldots$ \CASE{} $label_{n1} \l dots label_{nj_n}$ $e_n: s_n$ \}}, it is a compile-time error if the expressions $e_k$ are not compile-time constants for all $k \in 1..n$. It is a compile-ti me error if the values of the expressions $e_k$ are not either:
4772 \begin{itemize}
4773 \item instances of the same class $C$, for all $k \in 1..n$, or
4774 \item instances of a class that implements \cd{int}, for all $k \in 1..n$, or
4775 \item instances of a class that implements \cd{String}, for all $k \in 1..n$.
4776 \end{itemize}
4774 4777
4775 \commentary{In other words, all the expressions in the cases evaluate to consta nts of the exact same user defined class or are of certain known types. Note t hat the values of the expressions are known at compile-time, and are independent of any static type annotations. 4778 \commentary{In other words, all the expressions in the cases evaluate to consta nts of the exact same user defined class or are of certain known types. Note th at the values of the expressions are known at compile-time, and are independent of any static type annotations.
4776 } 4779 }
4777 4780
4778 It is a compile-time error if the class $C$ implements the operator $==$ unless the value of the expression is a string or integer. 4781 It is a compile-time error if the class $C$ has an implementation of the operato r $==$ other than the one inherited from \code{Object} unless the value of the e xpression is a string or an integer.
4779 4782
4780 \rationale{ 4783 \rationale{
4781 The prohibition on user defined equality allows us to implement the switch effi ciently for user defined types. We could formulate matching in terms of identity instead with the same efficiency. However, if a type defines an equality operat or, programmers would find it quite surprising that equal objects did not match. 4784 The prohibition on user defined equality allows us to implement the switch effi ciently for user defined types. We could formulate matching in terms of identity instead with the same efficiency. However, if a type defines an equality operat or, programmers would find it quite surprising that equal objects did not match.
4782 4785
4783 } 4786 }
4784 4787
4785 \commentary{ 4788 \commentary{
4786 The \SWITCH{} statement should only be used in very limited situations (e.g., i nterpreters or scanners). 4789 The \SWITCH{} statement should only be used in very limited situations (e.g., i nterpreters or scanners).
4787 } 4790 }
4788 4791
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
6083 \item The names of compile time constant variables never use lower case letters. If they consist of multiple words, those words are separated by underscores. Ex amples: PI, I\_AM\_A\_CONSTANT. 6086 \item The names of compile time constant variables never use lower case letters. If they consist of multiple words, those words are separated by underscores. Ex amples: PI, I\_AM\_A\_CONSTANT.
6084 \item The names of functions (including getters, setters, methods and local or l ibrary functions) and non-constant variables begin with a lowercase letter. If t he name consists of multiple words, each word (except the first) begins with an uppercase letter. No other uppercase letters are used. Examples: camlCase, dar t4TheWorld 6087 \item The names of functions (including getters, setters, methods and local or l ibrary functions) and non-constant variables begin with a lowercase letter. If t he name consists of multiple words, each word (except the first) begins with an uppercase letter. No other uppercase letters are used. Examples: camlCase, dar t4TheWorld
6085 \item The names of types (including classes and type aliases) begin with an uppe r case letter. If the name consists of multiple words, each word begins with an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D art4TheWorld. 6088 \item The names of types (including classes and type aliases) begin with an uppe r case letter. If the name consists of multiple words, each word begins with an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D art4TheWorld.
6086 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E. 6089 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E.
6087 \item The names of libraries or library prefixes never use upper case letters. I f they consist of multiple words, those words are separated by underscores. Exam ple: my\_favorite\_library. 6090 \item The names of libraries or library prefixes never use upper case letters. I f they consist of multiple words, those words are separated by underscores. Exam ple: my\_favorite\_library.
6088 \end{itemize} 6091 \end{itemize}
6089 } 6092 }
6090 6093
6091 6094
6092 \end{document} 6095 \end{document}
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