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.6}} | 8 {\large Version 1.6}} |
9 %\author{The Dart Team} | 9 %\author{The Dart Team} |
10 \begin{document} | 10 \begin{document} |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 . | 1325 . |
1326 \end{grammar} | 1326 \end{grammar} |
1327 | 1327 |
1328 | 1328 |
1329 %\commentary{Spell out subtleties: a constant constructor call within the initia
lizer of a constant constructor is treated as a ordinary constructor call (a ne
w), because the arguments cannot be assumed constant anymore. In practice, this
means two versions are compiled and analyzed. One for new and one for const.} | 1329 %\commentary{Spell out subtleties: a constant constructor call within the initia
lizer of a constant constructor is treated as a ordinary constructor call (a ne
w), because the arguments cannot be assumed constant anymore. In practice, this
means two versions are compiled and analyzed. One for new and one for const.} |
1330 | 1330 |
1331 % \Q{How to specify?} | 1331 % \Q{How to specify?} |
1332 | 1332 |
1333 \commentary{All the work of a constant constructor must be handled via its initi
alizers.} | 1333 \commentary{All the work of a constant constructor must be handled via its initi
alizers.} |
1334 | 1334 |
1335 It is a compile-time error if a constant constructor is declared by a class that
has a non-final instance variable. | 1335 It is a compile-time error if a constant constructor is declared by a class that
has a non-final instance variable. |
1336 | 1336 |
1337 \commentary{ | 1337 \commentary{ |
1338 The above refers to both locally declared and inherited instance variables. | 1338 The above refers to both locally declared and inherited instance variables. |
1339 } | 1339 } |
1340 | 1340 |
| 1341 It is a compile-time error if a constant constructor is declared by a class $C$
if any instance variable declared in $C$ is initialized with an expression that
is not a constant expression. |
| 1342 |
| 1343 \commentary { |
| 1344 A superclass of $C$ cannot declare such an initializer either, because it must n
ecessarily declare constant constructor as well (unless it is \code{Object}, whi
ch declares no instance variables). |
| 1345 } |
| 1346 |
1341 The superinitializer that appears, explicitly or implicitly, in the initializer
list of a constant constructor must specify a constant constructor of the superc
lass of the immediately enclosing class or a compile-time error occurs. | 1347 The superinitializer that appears, explicitly or implicitly, in the initializer
list of a constant constructor must specify a constant constructor of the superc
lass of the immediately enclosing class or a compile-time error occurs. |
1342 | 1348 |
1343 Any expression that appears within the initializer list of a constant constructo
r must be a potentially constant expression, or a compile-time error occurs. | 1349 Any expression that appears within the initializer list of a constant constructo
r must be a potentially constant expression, or a compile-time error occurs. |
1344 | 1350 |
1345 A {\em potentially constant expression} is an expression $e$ that would be a val
id constant expression if all formal parameters of $e$'s immediately enclosing c
onstant constructor were treated as compile-time constants that were guaranteed
to evaluate to an integer, boolean or string value as required by their immediat
ely enclosing superexpression. | 1351 A {\em potentially constant expression} is an expression $e$ that would be a val
id constant expression if all formal parameters of $e$'s immediately enclosing c
onstant constructor were treated as compile-time constants that were guaranteed
to evaluate to an integer, boolean or string value as required by their immediat
ely enclosing superexpression. |
1346 | 1352 |
1347 \commentary{ | 1353 \commentary{ |
1348 Note that a parameter that is not used in an superexpression that is restricted
to certain types can be a constant of any type. For example} | 1354 Note that a parameter that is not used in a superexpression that is restricted t
o certain types can be a constant of any type. For example} |
1349 | 1355 |
1350 \begin{dartCode} | 1356 \begin{dartCode} |
1351 \CLASS{} A \{ | 1357 \CLASS{} A \{ |
1352 \FINAL{} m; | 1358 \FINAL{} m; |
1353 \CONST{} A(this.m); | 1359 \CONST{} A(this.m); |
1354 \} | 1360 \} |
1355 \end{dartCode} | 1361 \end{dartCode} |
1356 | 1362 |
1357 \commentary{can be instantiated via \cd{\CONST{} A(\CONST []);}} | 1363 \commentary{can be instantiated via \cd{\CONST{} A(\CONST []);}} |
1358 | 1364 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 %\item If $d$ is of one of the forms \code{\STATIC{} \CONST{} $v$ = $e$; } or \
code{\STATIC{} \CONST{} $T$ $v$ = $e$;} the result of the getter is the value of
the compile time constant $e$. | 1478 %\item If $d$ is of one of the forms \code{\STATIC{} \CONST{} $v$ = $e$; } or \
code{\STATIC{} \CONST{} $T$ $v$ = $e$;} the result of the getter is the value of
the compile time constant $e$. |
1473 %Otherwise | 1479 %Otherwise |
1474 %\item The result of executing the getter method is the value stored in $v$. | 1480 %\item The result of executing the getter method is the value stored in $v$. |
1475 %\end{itemize} | 1481 %\end{itemize} |
1476 | 1482 |
1477 | 1483 |
1478 | 1484 |
1479 \subsection{Superclasses} | 1485 \subsection{Superclasses} |
1480 \label{superclasses} | 1486 \label{superclasses} |
1481 | 1487 |
1482 The superclass of a class $C$ that has a with clause \code{\WITH{} $M_1, \ldots,
M_k$} and an extends clause \code{\EXTENDS{} S} is the application of mixin (\r
ef{mixins}) $M_k* \cdots * M_1$ to S. If no with clause is specified then the
\EXTENDS{} clause of a class $C$ specifies its superclass. If no \EXTENDS{} cla
use is specified, then either: | 1488 The superclass of a class $C$ that has a with clause \code{\WITH{} $M_1, \ldots,
M_k$} and an extends clause \code{\EXTENDS{} S} is the application of mixin (\r
ef{mixins}) $M_k* \cdots * M_1$ to S. If no \WITH{} clause is specified then
the \EXTENDS{} clause of a class $C$ specifies its superclass. If no \EXTENDS{}
clause is specified, then either: |
1483 \begin{itemize} | 1489 \begin{itemize} |
1484 \item $C$ is \code{Object}, which has no superclass. OR | 1490 \item $C$ is \code{Object}, which has no superclass. OR |
1485 \item Class $C$ is deemed to have an \EXTENDS{} clause of the form \code{\EXTEN
DS{} Object}, and the rules above apply. | 1491 \item Class $C$ is deemed to have an \EXTENDS{} clause of the form \code{\EXTEN
DS{} Object}, and the rules above apply. |
1486 \end{itemize} | 1492 \end{itemize} |
1487 | 1493 |
1488 It is a compile-time error to specify an \EXTENDS{} clause for class \code{Objec
t}. | 1494 It is a compile-time error to specify an \EXTENDS{} clause for class \code{Objec
t}. |
1489 | 1495 |
1490 \begin{grammar} | 1496 \begin{grammar} |
1491 {\bf superclass:} | 1497 {\bf superclass:} |
1492 \EXTENDS{} type | 1498 \EXTENDS{} type |
(...skipping 3917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5410 % \item Let $T_i$ be the type parameters of $G$ (if any) and let $B_i$ be the b
ound of $T_i, i \in 1.. n$, and $S_i$ is not a subtype of $[S_1, \ldots, S_n/T
_1, \ldots, T_n]B_i, i \in 1.. n$. | 5416 % \item Let $T_i$ be the type parameters of $G$ (if any) and let $B_i$ be the b
ound of $T_i, i \in 1.. n$, and $S_i$ is not a subtype of $[S_1, \ldots, S_n/T
_1, \ldots, T_n]B_i, i \in 1.. n$. |
5411 % \end{itemize} | 5417 % \end{itemize} |
5412 \end{itemize} | 5418 \end{itemize} |
5413 | 5419 |
5414 Any use of a malformed type gives rise to a static warning. A malformed type i
s then interpreted as \DYNAMIC{} by the static type checker and the runtime unle
ss explicitly specified otherwise. | 5420 Any use of a malformed type gives rise to a static warning. A malformed type i
s then interpreted as \DYNAMIC{} by the static type checker and the runtime unle
ss explicitly specified otherwise. |
5415 | 5421 |
5416 \rationale{ | 5422 \rationale{ |
5417 This ensures that the developer is spared a series of cascading warnings as the
malformed type interacts with other types. | 5423 This ensures that the developer is spared a series of cascading warnings as the
malformed type interacts with other types. |
5418 } | 5424 } |
5419 | 5425 |
5420 A type $T$ is deferred iff it is of the form $p.T$ where $p$ is a deferred prefi
x. | 5426 A type $T$ is {\em deferred} iff it is of the form $p.T$ where $p$ is a deferred
prefix. |
5421 It is a static warning to use a deferred type in a type annotation, type test, t
ype cast or as a type parameter. However, all other static warnings must be issu
ed under the assumption that all deferred libraries have successfully been loade
d. | 5427 It is a static warning to use a deferred type in a type annotation, type test, t
ype cast or as a type parameter. However, all other static warnings must be issu
ed under the assumption that all deferred libraries have successfully been loade
d. |
5422 | 5428 |
5423 | 5429 |
5424 \subsubsection{Type Promotion} | 5430 \subsubsection{Type Promotion} |
5425 \label{typePromotion} | 5431 \label{typePromotion} |
5426 | 5432 |
5427 The static type system ascribes a static type to every expression. In some case
s, the types of local variables and formal parameters may be promoted from their
declared types based on control flow. | 5433 The static type system ascribes a static type to every expression. In some case
s, the types of local variables and formal parameters may be promoted from their
declared types based on control flow. |
5428 | 5434 |
5429 We say that a variable $v$ is known to have type $T$ whenever we allow the type
of $v$ to be promoted. The exact circumstances when type promotion is allowed ar
e given in the relevant sections of the specification (\ref{logicalBooleanExpres
sions}, \ref{conditional} and \ref{if}). | 5435 We say that a variable $v$ is known to have type $T$ whenever we allow the type
of $v$ to be promoted. The exact circumstances when type promotion is allowed ar
e given in the relevant sections of the specification (\ref{logicalBooleanExpres
sions}, \ref{conditional} and \ref{if}). |
5430 | 5436 |
5431 Type promotion for a variable $v$ is allowed only when we can deduce that such p
romotion is valid based on an analysis of certain boolean expressions. In such c
ases, we say that the boolean expression $b$ shows that $v$ has type $T$. As a r
ule, for all variables $v$ and types $T$, a boolean expression does not show tha
t $v$ has type $T$. Those situations where an expression does show that a variab
le has a type are mentioned explicitly in the relevant sections of this specific
ation (\ref{typeTest} and \ref{logicalBooleanExpressions}). | 5437 Type promotion for a variable $v$ is allowed only when we can deduce that such p
romotion is valid based on an analysis of certain boolean expressions. In such c
ases, we say that the boolean expression $b$ shows that $v$ has type $T$. As a r
ule, for all variables $v$ and types $T$, a boolean expression does not show tha
t $v$ has type $T$. Those situations where an expression does show that a variab
le has a type are mentioned explicitly in the relevant sections of this specific
ation (\ref{typeTest} and \ref{logicalBooleanExpressions}). |
5432 | 5438 |
5433 | 5439 |
5434 \subsection{Dynamic Type System} | 5440 \subsection{Dynamic Type System} |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6027 \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. | 6033 \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. |
6028 \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 | 6034 \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 |
6029 \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. | 6035 \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. |
6030 \item The names of type variables are short (preferably single letter). Examples
: T, S, K, V , E. | 6036 \item The names of type variables are short (preferably single letter). Examples
: T, S, K, V , E. |
6031 \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. | 6037 \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. |
6032 \end{itemize} | 6038 \end{itemize} |
6033 } | 6039 } |
6034 | 6040 |
6035 | 6041 |
6036 \end{document} | 6042 \end{document} |
OLD | NEW |