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 Draft Version 0.71}} | 8 {\large Draft Version 0.71}} |
9 \author{The Dart Team} | 9 \author{The Dart Team} |
10 \begin{document} | 10 \begin{document} |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 \ref{return}: Added warning if \RETURN{} without expression mixed with \RETURN{}
with an expression. | 504 \ref{return}: Added warning if \RETURN{} without expression mixed with \RETURN{}
with an expression. |
505 | 505 |
506 \ref{exports}: Ensure that exports treat \code{dart:} libs specially, like impor
ts do. | 506 \ref{exports}: Ensure that exports treat \code{dart:} libs specially, like impor
ts do. |
507 | 507 |
508 \ref{typePromotion}: Added notion of type promotion. | 508 \ref{typePromotion}: Added notion of type promotion. |
509 | 509 |
510 \ref{typedef}: Banned all recursion in typedefs. | 510 \ref{typedef}: Banned all recursion in typedefs. |
511 | 511 |
512 \subsubsection{Changes Since Version 0.7} | 512 \subsubsection{Changes Since Version 0.7} |
513 | 513 |
| 514 |
| 515 \ref{variables}: Final variables no longer introduce setters. |
| 516 |
514 \ref{new}: Instantiating subclasses of malbounded types is a dynamic error. | 517 \ref{new}: Instantiating subclasses of malbounded types is a dynamic error. |
515 | 518 |
516 \ref{leastUpperBounds}: Extended LUBs to all types. | 519 \ref{leastUpperBounds}: Extended LUBs to all types. |
517 | 520 |
518 | 521 |
519 | 522 |
520 \section{Notation} | 523 \section{Notation} |
521 \label{notation} | 524 \label{notation} |
522 | 525 |
523 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: | 526 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: |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 | 817 |
815 Taken as a whole, the rules ensure that any attempt to execute multiple assignme
nts to a final variable will yield static warnings and repeated assignments will
fail dynamically. | 818 Taken as a whole, the rules ensure that any attempt to execute multiple assignme
nts to a final variable will yield static warnings and repeated assignments will
fail dynamically. |
816 } | 819 } |
817 | 820 |
818 A {\em constant variable} is a variable whose declaration includes the modifier
\CONST{}. A constant variable is always implicitly final. A constant variable mu
st be initialized to a compile-time constant (\ref{constants}) or a compile-time
error occurs. | 821 A {\em constant variable} is a variable whose declaration includes the modifier
\CONST{}. A constant variable is always implicitly final. A constant variable mu
st be initialized to a compile-time constant (\ref{constants}) or a compile-time
error occurs. |
819 | 822 |
820 We say that a variable $v$ is {\em potentially mutated} in some scope $s$ if $v$
is not final or constant and an assignment to $v$ occurs in $s$. | 823 We say that a variable $v$ is {\em potentially mutated} in some scope $s$ if $v$
is not final or constant and an assignment to $v$ occurs in $s$. |
821 | 824 |
822 If a variable declaration does not explicitly specify a type, the type of the de
clared variable(s) is \DYNAMIC{}, the unknown type (\ref{typeDynamic}). | 825 If a variable declaration does not explicitly specify a type, the type of the de
clared variable(s) is \DYNAMIC{}, the unknown type (\ref{typeDynamic}). |
823 | 826 |
824 Static and instance variable declarations always induce implicit getters and set
ters. | 827 A variable is {\em mutable} if it is not final. |
| 828 Static and instance variable declarations always induce implicit getters. If the
variable is mutable it also introduces an implicit setter. |
825 The scope into which the implicit getters and setters are introduced depends on
the kind of variable declaration involved. | 829 The scope into which the implicit getters and setters are introduced depends on
the kind of variable declaration involved. |
826 | 830 |
827 A library variable introduces a getter and a setter into the top level scope of
the enclosing library. A static class variable introduces a static getter and a
static setter into the immediately enclosing class. An instance variable introdu
ces an instance getter and an instance setter into the immediately enclosing cla
ss. | 831 A library variable introduces a getter into the top level scope of the enclosing
library. A static class variable introduces a static getter into the immediatel
y enclosing class. An instance variable introduces an instance getter into the i
mmediately enclosing class. |
| 832 |
| 833 A mutable library variable introduces a setter into the top level scope of the e
nclosing library. A mutable static class variable introduces a static setter int
o the immediately enclosing class. A mutable instance variable introduces an ins
tance setter into the immediately enclosing class. |
828 | 834 |
829 Local variables are added to the innermost enclosing scope. They do not induce
getters and setters. A local variable may only be referenced at a source code l
ocation that is after its initializer, if any, is complete, or a compile-time er
ror occurs. The error may be reported either at the point where the premature r
eference occurs, or at the variable declaration. | 835 Local variables are added to the innermost enclosing scope. They do not induce
getters and setters. A local variable may only be referenced at a source code l
ocation that is after its initializer, if any, is complete, or a compile-time er
ror occurs. The error may be reported either at the point where the premature r
eference occurs, or at the variable declaration. |
830 | 836 |
831 \rationale { | 837 \rationale { |
832 We allow the error to be reported at the declaration to allow implementations to
avoid an extra processing phase. | 838 We allow the error to be reported at the declaration to allow implementations to
avoid an extra processing phase. |
833 } | 839 } |
834 | 840 |
835 \commentary{ | 841 \commentary{ |
836 The example below illustrates the expected behavior. A variable $x$ is declared
at the library level, and another $x$ is declared inside the function $f$. | 842 The example below illustrates the expected behavior. A variable $x$ is declared
at the library level, and another $x$ is declared inside the function $f$. |
837 } | 843 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 \VOID{} \SET{} $v=(T$ $x)$ | 908 \VOID{} \SET{} $v=(T$ $x)$ |
903 | 909 |
904 whose execution sets the value of $v$ to the incoming argument $x$. | 910 whose execution sets the value of $v$ to the incoming argument $x$. |
905 | 911 |
906 A non-final variable declaration of the form \code{\VAR{} $v$;} or the form \
code{\VAR{} $v$ = $e$;} always induces an implicit setter function with signa
ture | 912 A non-final variable declaration of the form \code{\VAR{} $v$;} or the form \
code{\VAR{} $v$ = $e$;} always induces an implicit setter function with signa
ture |
907 | 913 |
908 \SET{} $v=(x)$ | 914 \SET{} $v=(x)$ |
909 | 915 |
910 whose execution sets the value of $v$ to the incoming argument $x$. | 916 whose execution sets the value of $v$ to the incoming argument $x$. |
911 | 917 |
912 % A final variable introduces a setter that throws and causes a type warning | |
913 | |
914 A final or constant variable declaration of the form \code{\FINAL{} $T$ $v$;},
\code{\FINAL{} $T$ $v$ = $e$;} or the form \code{\CONST{} $T$ $v$ = $e$;} alw
ays induces an implicit setter function (\ref{setters}) with signature | |
915 | |
916 \VOID{} \SET{} $v=(T$ $x)$ | |
917 | |
918 whose execution causes a runtime exception. It is a static warning to invoke suc
h a setter. | |
919 | |
920 A final variable declaration of the form \code{\FINAL{} $v$;}, \code{\FINAL{}
$v$ = $e$;} or the form \code{\CONST{} $v$ = $e$;} always induces an implici
t setter function with signature | |
921 | |
922 \SET{} $v=(x)$ | |
923 | |
924 whose execution causes a runtime exception. It is a static warning to invoke suc
h a setter. % maybe redundant with rules for assignment? | |
925 | |
926 \rationale{ | |
927 Creating a setter that may not be used may seem pointless, but it prevents situa
tions where a setter from an enclosing scope might be accidentally accessed from
a scope that defines an immutable variable. | |
928 } | |
929 | |
930 | 918 |
931 \subsection{Evaluation of Implicit Variable Getters} | 919 \subsection{Evaluation of Implicit Variable Getters} |
932 \label{evaluationOfImplicitVariableGetters} | 920 \label{evaluationOfImplicitVariableGetters} |
933 | 921 |
934 Let $d$ be the declaration of a static or instance variable $v$. If $d$ is an i
nstance variable, then the invocation of the implicit getter of $v$ evaluates t
o the value stored in $v$. | 922 Let $d$ be the declaration of a static or instance variable $v$. If $d$ is an i
nstance variable, then the invocation of the implicit getter of $v$ evaluates t
o the value stored in $v$. |
935 If $d$ is a static or library variable then the implicit getter method of $v$ ex
ecutes as follows: | 923 If $d$ is a static or library variable then the implicit getter method of $v$ ex
ecutes as follows: |
936 \begin{itemize} | 924 \begin{itemize} |
937 \item {\bf Non-constant variable declaration with initializer}. If $d$ is of one
of the forms \code{\VAR{} $v$ = $e$;} , \code{$T$ $v$ = $e$;} , \code{\FINAL
{} $v$ = $e$;} , \code{\FINAL{} $T$ $v$ = $e$;}, \code{\STATIC{} $v$ = $e$; },
\code{\STATIC{} $T$ $v$ = $e$; }, \code{\STATIC{} \FINAL{} $v$ = $e$; } or \code
{\STATIC{} \FINAL{} $T$ $v$ = $e$;} and no value has yet been stored into $v$ th
en the initializer expression $e$ is evaluated. If, during the evaluation of $e$
, the getter for $v$ is invoked, a \code{CyclicInitializationError} is thrown. I
f the evaluation succeeded yielding an object $o$, let $r = o$, otherwise let $r
= \NULL{}$. In any case, $r$ is stored into $v$. The result of executing the ge
tter is $r$. | 925 \item {\bf Non-constant variable declaration with initializer}. If $d$ is of one
of the forms \code{\VAR{} $v$ = $e$;} , \code{$T$ $v$ = $e$;} , \code{\FINAL
{} $v$ = $e$;} , \code{\FINAL{} $T$ $v$ = $e$;}, \code{\STATIC{} $v$ = $e$; },
\code{\STATIC{} $T$ $v$ = $e$; }, \code{\STATIC{} \FINAL{} $v$ = $e$; } or \code
{\STATIC{} \FINAL{} $T$ $v$ = $e$;} and no value has yet been stored into $v$ th
en the initializer expression $e$ is evaluated. If, during the evaluation of $e$
, the getter for $v$ is invoked, a \code{CyclicInitializationError} is thrown. I
f the evaluation succeeded yielding an object $o$, let $r = o$, otherwise let $r
= \NULL{}$. In any case, $r$ is stored into $v$. The result of executing the ge
tter is $r$. |
938 \item {\bf Constant variable declaration}. If $d$ is of one of the forms \code{
\CONST{} $v$ = $e$; } , \code{\CONST{} $T$ $v$ = $e$; }, \code{\STATIC{} \CON
ST{} $v$ = $e$; } or \code{\STATIC{} \CONST{} $T$ $v$ = $e$;} the result of the
getter is the value of the compile time constant $e$. \commentary{Note that a c
ompile time constant cannot depend on itself, so no cyclic references can occur.
} | 926 \item {\bf Constant variable declaration}. If $d$ is of one of the forms \code{
\CONST{} $v$ = $e$; } , \code{\CONST{} $T$ $v$ = $e$; }, \code{\STATIC{} \CON
ST{} $v$ = $e$; } or \code{\STATIC{} \CONST{} $T$ $v$ = $e$;} the result of the
getter is the value of the compile time constant $e$. \commentary{Note that a c
ompile time constant cannot depend on itself, so no cyclic references can occur.
} |
939 Otherwise | 927 Otherwise |
(...skipping 5227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6167 \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. | 6155 \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. |
6168 \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 | 6156 \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 |
6169 \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. | 6157 \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. |
6170 \item The names of type variables are short (preferably single letter). Examples
: T, S, K, V , E. | 6158 \item The names of type variables are short (preferably single letter). Examples
: T, S, K, V , E. |
6171 \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. | 6159 \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. |
6172 \end{itemize} | 6160 \end{itemize} |
6173 } | 6161 } |
6174 | 6162 |
6175 | 6163 |
6176 \end{document} | 6164 \end{document} |
OLD | NEW |