OLD | NEW |
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 Version 1.2}} | 8 {\large Version 1.3}} |
9 \author{The Dart Team} | 9 %\author{The Dart Team} |
10 \begin{document} | 10 \begin{document} |
11 \maketitle | 11 \maketitle |
12 | |
13 \tableofcontents | 12 \tableofcontents |
14 | 13 |
15 | 14 |
16 \newpage | 15 \newpage |
17 | 16 |
18 \pagestyle{myheadings} | 17 \pagestyle{myheadings} |
19 \markright{Dart Programming Language Specification} | 18 \markright{Dart Programming Language Specification} |
20 | 19 |
21 \section{Notes} | 20 % begin Ecma boilerplate |
| 21 \section{Scope} |
| 22 \label{ecmaScope} |
22 | 23 |
23 \subsection{Licensing} | 24 This Ecma standard specifies the syntax and semantics of the Dart programming la
nguage. It does not specify the APIs of the Dart libraries except where those l
ibrary elements are essential to the correct functioning of the language itself
(e.g., the existence of class \cd{Object} with methods such as \cd{noSuchMethod}
, \cd{runtimeType}). |
24 \label{licensing} | 25 |
| 26 \section{Conformance} |
| 27 \label{ecmaConformance} |
| 28 |
| 29 A conforming implementation of the Dart programming language must provide and s
upport all the APIs (libraries, types, functions, getters, setters, whether top
-level, static, instance or local) mandated in this specification. |
| 30 |
| 31 A conforming implementation is permitted to provide additional APIs, but not add
itional syntax, except for experimental features in support of enumerated types
and deferred loading which are expected to be added in the next revision of this
specification. |
| 32 |
| 33 % A claim of conformance with this Ecma Standard shall specify? |
| 34 |
| 35 \section{Normative References} |
| 36 \label{ecmaNormativeReferences} |
| 37 |
| 38 The following referenced documents are indispensable for the application of this
document. For dated references, only the edition cited applies. For undated ref
erences, the latest edition of the referenced document (including any amendments
) applies. |
| 39 |
| 40 \begin{enumerate} |
| 41 \item |
| 42 The Unicode Standard, Version 5.0, as amended by Unicode 5.1.0, or successor. |
| 43 \item |
| 44 Dart API Reference, https://api.dartlang.org/ |
| 45 \end{enumerate} |
25 | 46 |
26 | 47 |
27 Except as otherwise noted at https://developers.google.com/site-policies, the co
ntent of this document is licensed under the Creative Commons Attribution 3.0 Li
cense available at: | 48 \section{Terms and Definitions} |
| 49 \label{ecmaTermsAndDefinitions} |
28 | 50 |
29 http://creativecommons.org/licenses/by/3.0/ | 51 Terms and definitions used in this specification are given in the body of the sp
ecification proper. Such terms are highlighted in italics when they are introduc
ed, e.g., `we use the term {\em verbosity} to refer to the property of excess ve
rbiage'. |
30 | 52 % End Ecma Boilerplate |
31 and code samples are licensed under the license available at | 53 |
32 | |
33 https://code.google.com/p/dart/source/browse/trunk/dart/LICENSE. | |
34 | 54 |
35 \section{Notation} | 55 \section{Notation} |
36 \label{notation} | 56 \label{notation} |
37 | 57 |
38 We distinguish between normative and non-normative text. Normative text defines
the rules of Dart. It is given in this font. At this time, non-normative text in
cludes: | 58 We distinguish between normative and non-normative text. Normative text defines
the rules of Dart. It is given in this font. At this time, non-normative text in
cludes: |
39 \begin{itemize} | 59 \begin{itemize} |
40 \item[Rationale] Discussion of the motivation for language design decisions appe
ars in italics. \rationale{Distinguishing normative from non-normative helps cla
rify what part of the text is binding and what part is merely expository.} | 60 \item[Rationale] Discussion of the motivation for language design decisions appe
ars in italics. \rationale{Distinguishing normative from non-normative helps cla
rify what part of the text is binding and what part is merely expository.} |
41 \item[Commentary] Comments such as ``\commentary{The careful reader will have n
oticed that the name Dart has four characters}'' serve to illustrate or clarify
the specification, but are redundant with the normative text. \commentary{The d
ifference between commentary and rationale can be subtle.} \rationale{ Commentar
y is more general than rationale, and may include illustrative examples or clari
fications. } | 61 \item[Commentary] Comments such as ``\commentary{The careful reader will have n
oticed that the name Dart has four characters}'' serve to illustrate or clarify
the specification, but are redundant with the normative text. \commentary{The d
ifference between commentary and rationale can be subtle.} \rationale{ Commentar
y is more general than rationale, and may include illustrative examples or clari
fications. } |
42 \item[Open questions] (\Q{in this font}). Open questions are points that are uns
ettled in the mind of the author(s) of the specification; expect them (the quest
ions, not the authors; precision is important in a specification) to be eliminat
ed in the final specification. \Q{Should the text at the end of the previous bul
let be rationale or commentary?} | 62 \item[Open questions] (\Q{in this font}). Open questions are points that are uns
ettled in the mind of the author(s) of the specification; expect them (the quest
ions, not the authors; precision is important in a specification) to be eliminat
ed in the final specification. \Q{Should the text at the end of the previous bul
let be rationale or commentary?} |
43 \end{itemize} | 63 \end{itemize} |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 It is a static warning if the return type of the user-declared operator \code{[]
=} is explicitly declared and not \VOID{}. | 873 It is a static warning if the return type of the user-declared operator \code{[]
=} is explicitly declared and not \VOID{}. |
854 | 874 |
855 | 875 |
856 \subsection{Getters} | 876 \subsection{Getters} |
857 \label{getters} | 877 \label{getters} |
858 | 878 |
859 Getters are functions (\ref{functions}) that are used to retrieve the values of
object properties. | 879 Getters are functions (\ref{functions}) that are used to retrieve the values of
object properties. |
860 | 880 |
861 \begin{grammar} | 881 \begin{grammar} |
862 {\bf getterSignature:} | 882 {\bf getterSignature:} |
863 type? \GET{} identifier | 883 returnType? \GET{} identifier |
864 . | 884 . |
865 \end{grammar} | 885 \end{grammar} |
866 | 886 |
867 %\Q{Why does a getter have a formal parameter list at all?} | 887 %\Q{Why does a getter have a formal parameter list at all?} |
868 | 888 |
869 If no return type is specified, the return type of the getter is \DYNAMIC{}. | 889 If no return type is specified, the return type of the getter is \DYNAMIC{}. |
870 | 890 |
871 A getter definition that is prefixed with the \STATIC{} modifier defines a stati
c getter. Otherwise, it defines an instance getter. The name of the getter is gi
ven by the identifier in the definition. | 891 A getter definition that is prefixed with the \STATIC{} modifier defines a stati
c getter. Otherwise, it defines an instance getter. The name of the getter is gi
ven by the identifier in the definition. |
872 | 892 |
873 %It is a compile-time error if a getter`s formal parameter list is not empty. | 893 %It is a compile-time error if a getter`s formal parameter list is not empty. |
874 | 894 |
875 The instance getters of a class $C$ are those instance getters declared by $C$,
either implicitly or explicitly, and the instance getters inherited by $C$ from
its superclass. The static getters of a class $C$ are those static getters decla
red by $C$. | 895 The instance getters of a class $C$ are those instance getters declared by $C$,
either implicitly or explicitly, and the instance getters inherited by $C$ from
its superclass. The static getters of a class $C$ are those static getters decla
red by $C$. |
876 | 896 |
877 It is a compile-time error if a class has both a getter and a method with the sa
me name. This restriction holds regardless of whether the getter is defined expl
icitly or implicitly, or whether the getter or the method are inherited or not. | 897 It is a compile-time error if a class has both a getter and a method with the sa
me name. This restriction holds regardless of whether the getter is defined expl
icitly or implicitly, or whether the getter or the method are inherited or not. |
878 | 898 |
879 \commentary{ | 899 \commentary{ |
880 This implies that a getter can never override a method, and a method can never o
verride a getter or field. | 900 This implies that a getter can never override a method, and a method can never o
verride a getter or field. |
881 } | 901 } |
882 | 902 |
| 903 It is a static warning if the return type of a getter is \VOID. |
883 It is a static warning if a getter $m_1$ overrides (\ref{inheritanceAndOverridi
ng}) a getter | 904 It is a static warning if a getter $m_1$ overrides (\ref{inheritanceAndOverridi
ng}) a getter |
884 $m_2$ and the type of $m_1$ is not a subtype of the type of $m_2$. | 905 $m_2$ and the type of $m_1$ is not a subtype of the type of $m_2$. |
885 | 906 |
886 It is a static warning if a class declares a static getter named $v$ and also h
as a non-static setter named $v=$. It is a static warning if a class $C$ declare
s an instance getter named $v$ and an accessible static member named $v$ or $v=$
is declared in a superclass of $C$. These warnings must be issued regardless of
whether the getters or setters are declared explicitly or implicitly. | 907 It is a static warning if a class declares a static getter named $v$ and also h
as a non-static setter named $v=$. It is a static warning if a class $C$ declare
s an instance getter named $v$ and an accessible static member named $v$ or $v=$
is declared in a superclass of $C$. These warnings must be issued regardless of
whether the getters or setters are declared explicitly or implicitly. |
887 | 908 |
888 \subsection{Setters} | 909 \subsection{Setters} |
889 \label{setters} | 910 \label{setters} |
890 | 911 |
891 Setters are functions (\ref{functions}) that are used to set the values of objec
t properties. | 912 Setters are functions (\ref{functions}) that are used to set the values of objec
t properties. |
892 | 913 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 \commentary{ | 1248 \commentary{ |
1228 It follows that if $type$ or $type.id$ are not defined, or do not refer to a cla
ss or constructor, a dynamic error occurs, as with any other undefined construct
or call. The same holds if $k$ is called with fewer required parameters or more
positional parameters than $k^\prime$ expects, or if $k$ is called with a named
parameter that is not declared by $k^\prime$. | 1249 It follows that if $type$ or $type.id$ are not defined, or do not refer to a cla
ss or constructor, a dynamic error occurs, as with any other undefined construct
or call. The same holds if $k$ is called with fewer required parameters or more
positional parameters than $k^\prime$ expects, or if $k$ is called with a named
parameter that is not declared by $k^\prime$. |
1229 } | 1250 } |
1230 | 1251 |
1231 It is a compile-time error if $k$ explicitly specifies a default value for an op
tional parameter.\commentary{ | 1252 It is a compile-time error if $k$ explicitly specifies a default value for an op
tional parameter.\commentary{ |
1232 Default values specified in $k$ would be ignored, since it is the {\em actual} p
arameters that are passed to $k^\prime$. Hence, default values are disallowed. | 1253 Default values specified in $k$ would be ignored, since it is the {\em actual} p
arameters that are passed to $k^\prime$. Hence, default values are disallowed. |
1233 } | 1254 } |
1234 | 1255 |
1235 It is a compile-time error if a redirecting factory constructor redirects to its
elf, either directly or indirectly via a sequence of redirections. %does not red
irect to a non-redirecting factory constructor or to a generative constructor in
a finite number of steps. | 1256 It is a compile-time error if a redirecting factory constructor redirects to its
elf, either directly or indirectly via a sequence of redirections. %does not red
irect to a non-redirecting factory constructor or to a generative constructor in
a finite number of steps. |
1236 | 1257 |
| 1258 % Make this a runtime error so deferred loading works |
| 1259 |
1237 \rationale{ | 1260 \rationale{ |
1238 If a redirecting factory $F_1$ redirects to another redirecting factory $F_2$ an
d $F_2$ then redirects to $F_1$, then both $F_1$ and $F_2$ are ill-defined. Such
cycles are therefore illegal. | 1261 If a redirecting factory $F_1$ redirects to another redirecting factory $F_2$ an
d $F_2$ then redirects to $F_1$, then both $F_1$ and $F_2$ are ill-defined. Such
cycles are therefore illegal. |
1239 } | 1262 } |
1240 | 1263 |
1241 | 1264 |
1242 It is a static warning if $type$ does not denote a class accessible in the curre
nt scope; if $type$ does denote such a class $C$ it is a static warning if the r
eferenced constructor (be it $type$ or $type.id$) is not a constructor of $C$. | 1265 It is a static warning if $type$ does not denote a class accessible in the curre
nt scope; if $type$ does denote such a class $C$ it is a static warning if the r
eferenced constructor (be it $type$ or $type.id$) is not a constructor of $C$. |
1243 | 1266 |
1244 \commentary{ | 1267 \commentary{ |
1245 Note that it is not possible to modify the arguments being passed to $k'$. | 1268 Note that it is not possible to modify the arguments being passed to $k'$. |
1246 } | 1269 } |
(...skipping 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 IDENTIFIER\_START\_NO\_DOLLAR IDENTIFIER\_PART\_NO\_DOLLAR* | 3900 IDENTIFIER\_START\_NO\_DOLLAR IDENTIFIER\_PART\_NO\_DOLLAR* |
3878 . | 3901 . |
3879 | 3902 |
3880 {\bf IDENTIFIER:} | 3903 {\bf IDENTIFIER:} |
3881 IDENTIFIER\_START IDENTIFIER\_PART* | 3904 IDENTIFIER\_START IDENTIFIER\_PART* |
3882 . | 3905 . |
3883 | 3906 |
3884 {\bf BUILT\_IN\_IDENTIFIER:} \ABSTRACT{}; | 3907 {\bf BUILT\_IN\_IDENTIFIER:} \ABSTRACT{}; |
3885 \AS{}; | 3908 \AS{}; |
3886 % \ASSERT{}; | 3909 % \ASSERT{}; |
| 3910 \DEFERRED{}; |
3887 \DYNAMIC{}; | 3911 \DYNAMIC{}; |
3888 \EXPORT{}; | 3912 \EXPORT{}; |
3889 \EXTERNAL{}; | 3913 \EXTERNAL{}; |
3890 \FACTORY{}; | 3914 \FACTORY{}; |
3891 \GET{}; | 3915 \GET{}; |
3892 \IMPLEMENTS{}; | 3916 \IMPLEMENTS{}; |
3893 \IMPORT{}; | 3917 \IMPORT{}; |
3894 \LIBRARY{}; | 3918 \LIBRARY{}; |
3895 \OPERATOR{}; | 3919 \OPERATOR{}; |
3896 \PART{}; | 3920 \PART{}; |
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5633 A {\em parameterized type} is an invocation of a generic type declaration. | 5657 A {\em parameterized type} is an invocation of a generic type declaration. |
5634 | 5658 |
5635 Let $T$ be a parameterized type $G<S_1, \ldots, S_n>$. If $G$ is not a generic
type, the type arguments $S_i$, $1 \le i \le n$ are discarded. If $G$ has $m \n
e n$ type parameters, $T$ is treated as as a parameterized type with $m$ argumen
ts, all of which are \DYNAMIC{}. | 5659 Let $T$ be a parameterized type $G<S_1, \ldots, S_n>$. If $G$ is not a generic
type, the type arguments $S_i$, $1 \le i \le n$ are discarded. If $G$ has $m \n
e n$ type parameters, $T$ is treated as as a parameterized type with $m$ argumen
ts, all of which are \DYNAMIC{}. |
5636 | 5660 |
5637 \commentary{In short, any arity mismatch results in all type arguments being dro
pped, and replaced with the correct number of type arguments, all set to \DYNAMI
C{}. Of course, a static warning will be issued. | 5661 \commentary{In short, any arity mismatch results in all type arguments being dro
pped, and replaced with the correct number of type arguments, all set to \DYNAMI
C{}. Of course, a static warning will be issued. |
5638 } | 5662 } |
5639 | 5663 |
5640 Otherwise, let | 5664 Otherwise, let |
5641 $T_i$ be the type parameters of $G$ and let $B_i$ be the bound of $T_i, i \in
1.. n$,. $T$ is {\em malbounded} iff either $S_i$ is malbounded or $S_i$ is not
a subtype of $[S_1, \ldots, S_n/T_1, \ldots, T_n]B_i, i \in 1.. n$. | 5665 $T_i$ be the type parameters of $G$ and let $B_i$ be the bound of $T_i, i \in
1.. n$,. $T$ is {\em malbounded} iff either $S_i$ is malbounded or $S_i$ is not
a subtype of $[S_1, \ldots, S_n/T_1, \ldots, T_n]B_i, i \in 1.. n$. |
5642 | 5666 |
| 5667 \commentary{ |
5643 Note, that, in checked mode, it is a dynamic type error if a malbounded type is
used in a type test as specified in \ref{dynamicTypeSystem}. | 5668 Note, that, in checked mode, it is a dynamic type error if a malbounded type is
used in a type test as specified in \ref{dynamicTypeSystem}. |
| 5669 } |
5644 | 5670 |
5645 Any use of a malbounded type gives rise to a static warning. | 5671 Any use of a malbounded type gives rise to a static warning. |
5646 | 5672 |
5647 If $S$ is the static type of a member $m$ of $G$, then the static type of the me
mber $m$ of $G<A_1, \ldots, A_n>$ is $[A_1, \ldots, A_n/T_1, \ldots, T_n]S$
where $T_1, \ldots, T_n$ are the formal type parameters of $G$. Let $B_i$, be
the bounds of $T_i, 1 \le i \le n$. It is a static type warning if $A_i$ is not
a subtype of $[A_1, \ldots, A_n/T_1, \ldots, T_n]B_i, i \in 1..n$. It is a s
tatic type warning if $G$ is not a generic type with exactly $n$ type parameters
. | 5673 If $S$ is the static type of a member $m$ of $G$, then the static type of the me
mber $m$ of $G<A_1, \ldots, A_n>$ is $[A_1, \ldots, A_n/T_1, \ldots, T_n]S$
where $T_1, \ldots, T_n$ are the formal type parameters of $G$. Let $B_i$, be
the bounds of $T_i, 1 \le i \le n$. It is a static type warning if $A_i$ is not
a subtype of $[A_1, \ldots, A_n/T_1, \ldots, T_n]B_i, i \in 1..n$. It is a s
tatic type warning if $G$ is not a generic type with exactly $n$ type parameters
. |
5648 | 5674 |
5649 | 5675 |
5650 | 5676 |
5651 | 5677 |
5652 | 5678 |
5653 \subsubsection{Actual Type of Declaration} | 5679 \subsubsection{Actual Type of Declaration} |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5842 \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. | 5868 \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. |
5843 \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 | 5869 \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 |
5844 \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. | 5870 \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. |
5845 \item The names of type variables are short (preferably single letter). Examples
: T, S, K, V , E. | 5871 \item The names of type variables are short (preferably single letter). Examples
: T, S, K, V , E. |
5846 \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. | 5872 \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. |
5847 \end{itemize} | 5873 \end{itemize} |
5848 } | 5874 } |
5849 | 5875 |
5850 | 5876 |
5851 \end{document} | 5877 \end{document} |
OLD | NEW |