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

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}
11 \maketitle 11 \maketitle
12 12
13 \tableofcontents 13 \tableofcontents
rmacnak 2013/10/09 20:54:43 Stray whitespace.
14 14
15 \newpage 15 \newpage
16 16
17 \pagestyle{myheadings} 17 \pagestyle{myheadings}
18 \markright{{\bf Draft} Dart Programming Language Specification {\bf Draft}} 18 \markright{{\bf Draft} Dart Programming Language Specification {\bf Draft}}
19 19
20 \section{Notes} 20 \section{Notes}
21 21
22 Expect the contents and language rules to change over time. 22 Expect the contents and language rules to change over time.
23 %Please mail comments to gbracha@google.com. 23 %Please mail comments to gbracha@google.com.
(...skipping 2330 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 all instances of the same class $C$ or
4774 \item instances of a class that implements \cd{int} or \cd{String}, for all $k \in 1..n$.
rmacnak 2013/10/09 20:54:43 I read this as allowing mixture of ints and String
4775 \end{itemize}
4774 4776
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. 4777 \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 } 4778 }
4777 4779
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. 4780 It is a compile-time error if the class $C$ has an implementation the operator $ ==$ other than the one inherited from \code{Object} unless the value of the expr ession is a string or an integer.
rmacnak 2013/10/09 20:54:43 has an implementation with the operator ==
4779 4781
4780 \rationale{ 4782 \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. 4783 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 4784
4783 } 4785 }
4784 4786
4785 \commentary{ 4787 \commentary{
4786 The \SWITCH{} statement should only be used in very limited situations (e.g., i nterpreters or scanners). 4788 The \SWITCH{} statement should only be used in very limited situations (e.g., i nterpreters or scanners).
4787 } 4789 }
4788 4790
(...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. 6085 \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 6086 \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. 6087 \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. 6088 \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. 6089 \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} 6090 \end{itemize}
6089 } 6091 }
6090 6092
6091 6093
6092 \end{document} 6094 \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