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 2854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2865 | 2865 |
2866 \begin{grammar} | 2866 \begin{grammar} |
2867 {\bf symbolLiteral:} | 2867 {\bf symbolLiteral:} |
2868 `\#' (operator $|$ (identifier (`{\escapegrammar .}' identifier)*)) . | 2868 `\#' (operator $|$ (identifier (`{\escapegrammar .}' identifier)*)) . |
2869 \end{grammar} | 2869 \end{grammar} |
2870 | 2870 |
2871 \LMHash{} | 2871 \LMHash{} |
2872 A symbol literal \code{\#id} where \code{id} does not begin with an underscore ( '\code{\_}') is equivalent to the expression \code{\CONST{} Symbol('id')}. | 2872 A symbol literal \code{\#id} where \code{id} does not begin with an underscore ( '\code{\_}') is equivalent to the expression \code{\CONST{} Symbol('id')}. |
2873 | 2873 |
2874 \LMHash{} | 2874 \LMHash{} |
2875 A symbol literal \code{\#\_id} evaluates to the object that would be returned by the call \code{mirror.getPrivateSymbol('id')} where mirror is an instance of th e class \code{LibraryMirror} defined in the library \code{dart:mirrors}, reflect ing the current library. | 2875 A symbol literal \code{\#\_id} evaluates to the object that would be returned by the call \code{MirrorSystem.getSymbol('_id', mirror)} where \code{mirror} is an instance of the class \code{LibraryMirror} defined in the library \code{dart:mi rrors}, reflecting the current library. |
eernst
2016/09/28 11:35:00
I'd prefer calling it \code{libraryMirror}, giving
Lasse Reichstein Nielsen
2016/09/28 11:38:26
Done.
| |
2876 | 2876 |
2877 \rationale{ | 2877 \rationale{ |
2878 One may well ask what is the motivation for introducing literal symbols? In some languages, symbols are canonicalized whereas strings are not. However literal s trings are already canonicalized in Dart. Symbols are slightly easier to type c ompared to strings and their use can become strangely addictive, but this is not nearly sufficient justification for adding a literal form to the language. The primary motivation is related to the use of reflection and a web specific practi ce known as minification. | 2878 One may well ask what is the motivation for introducing literal symbols? In some languages, symbols are canonicalized whereas strings are not. However literal s trings are already canonicalized in Dart. Symbols are slightly easier to type c ompared to strings and their use can become strangely addictive, but this is not nearly sufficient justification for adding a literal form to the language. The primary motivation is related to the use of reflection and a web specific practi ce known as minification. |
2879 | 2879 |
2880 Minification compresses identifiers consistently throughout a program in order t o reduce download size. This practice poses difficulties for reflective program s that refer to program declarations via strings. A string will refer to an iden tifier in the source, but the identifier will no longer be used in the minified code, and reflective code using these would fail. Therefore, Dart reflection us es objects of type \code{Symbol} rather than strings. Instances of \code{Symbol } are guaranteed to be stable with repeat to minification. Providing a literal f orm for symbols makes reflective code easier to read and write. The fact that sy mbols are easy to type and can often act as convenient substitutes for enums are secondary benefits. | 2880 Minification compresses identifiers consistently throughout a program in order t o reduce download size. This practice poses difficulties for reflective program s that refer to program declarations via strings. A string will refer to an iden tifier in the source, but the identifier will no longer be used in the minified code, and reflective code using these would fail. Therefore, Dart reflection us es objects of type \code{Symbol} rather than strings. Instances of \code{Symbol } are guaranteed to be stable with repeat to minification. Providing a literal f orm for symbols makes reflective code easier to read and write. The fact that sy mbols are easy to type and can often act as convenient substitutes for enums are secondary benefits. |
2881 } | 2881 } |
2882 | 2882 |
2883 \LMHash{} | 2883 \LMHash{} |
2884 The static type of a symbol literal is \code{Symbol}. | 2884 The static type of a symbol literal is \code{Symbol}. |
2885 | 2885 |
(...skipping 5011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7897 | 7897 |
7898 The invariant that each normative paragraph is associated with a line | 7898 The invariant that each normative paragraph is associated with a line |
7899 containing the text \LMHash{} should be maintained. Extra occurrences | 7899 containing the text \LMHash{} should be maintained. Extra occurrences |
7900 of \LMHash{} can be added if needed, e.g., in order to make | 7900 of \LMHash{} can be added if needed, e.g., in order to make |
7901 individual \item{}s in itemized lists addressable. Each \LM.. command | 7901 individual \item{}s in itemized lists addressable. Each \LM.. command |
7902 must occur on a separate line. \LMHash{} must occur immediately | 7902 must occur on a separate line. \LMHash{} must occur immediately |
7903 before the associated paragraph, and \LMLabel must occur immediately | 7903 before the associated paragraph, and \LMLabel must occur immediately |
7904 after the associated \section{}, \subsection{} etc. | 7904 after the associated \section{}, \subsection{} etc. |
7905 | 7905 |
7906 ---------------------------------------------------------------------- | 7906 ---------------------------------------------------------------------- |
OLD | NEW |