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 {\large Version 1.9}} | 10 {\large Version 1.9}} |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 | 751 |
752 \rationale{ | 752 \rationale{ |
753 The need for this restriction is a direct consequence of the fact that naming a nd privacy are not orthogonal. | 753 The need for this restriction is a direct consequence of the fact that naming a nd privacy are not orthogonal. |
754 If we allowed named parameters to begin with an underscore, they would be consid ered private and inaccessible to callers from outside the library where it was d efined. If a method outside the library overrode a method with a private optiona l name, it would not be a subtype of the original method. The static checker wou ld of course flag such situations, but the consequence would be that adding a pr ivate named formal would break clients outside the library in a way they could n ot easily correct. | 754 If we allowed named parameters to begin with an underscore, they would be consid ered private and inaccessible to callers from outside the library where it was d efined. If a method outside the library overrode a method with a private optiona l name, it would not be a subtype of the original method. The static checker wou ld of course flag such situations, but the consequence would be that adding a pr ivate named formal would break clients outside the library in a way they could n ot easily correct. |
755 } | 755 } |
756 | 756 |
757 \subsection{Type of a Function} | 757 \subsection{Type of a Function} |
758 \LMLabel{typeOfAFunction} | 758 \LMLabel{typeOfAFunction} |
759 | 759 |
760 \LMHash{} | 760 \LMHash{} |
761 If a function does not declare a return type explicitly, its return type is \DYN AMIC{} (\ref{typeDynamic}). | 761 If a function does not declare a return type explicitly, its return type is \DYN AMIC{} (\ref{typeDynamic}), unless it is a constructor function, in which case i ts return type is the immediately enclosing class. |
762 | 762 |
763 \LMHash{} | 763 \LMHash{} |
764 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and no optional parameters. Then the type of $F$ is $(T_1 ,\ldots, T_n) \rightarrow T_0$. | 764 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and no optional parameters. Then the type of $F$ is $(T_1 ,\ldots, T_n) \rightarrow T_0$. |
765 | 765 |
766 \LMHash{} | 766 \LMHash{} |
767 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and positional optional parameters $T_{n+1}$ $p_{n+1}, \l dots, T_{n+k}$ $ p_{n+k}$. Then the type of $F$ is $(T_1 ,\ldots, T_n, [T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}]) \rightarrow T_0$. | 767 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and positional optional parameters $T_{n+1}$ $p_{n+1}, \l dots, T_{n+k}$ $ p_{n+k}$. Then the type of $F$ is $(T_1 ,\ldots, T_n, [T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}]) \rightarrow T_0$. |
768 | 768 |
769 \LMHash{} | 769 \LMHash{} |
770 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and named optional parameters $T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $ p_{n+k}$. Then the type of $F$ is $(T_1 ,\ldots, T_n, \{T_{n+1}$ $p_ {n+1}, \ldots, T_{n+k}$ $p_{n+k}\}) \rightarrow T_0$. | 770 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and named optional parameters $T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $ p_{n+k}$. Then the type of $F$ is $(T_1 ,\ldots, T_n, \{T_{n+1}$ $p_ {n+1}, \ldots, T_{n+k}$ $p_{n+k}\}) \rightarrow T_0$. |
771 | 771 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
852 | 852 |
853 {\bf staticFinalDeclaration:} | 853 {\bf staticFinalDeclaration:} |
854 identifier `=' expression | 854 identifier `=' expression |
855 . | 855 . |
856 | 856 |
857 \end{grammar} | 857 \end{grammar} |
858 | 858 |
859 \LMHash{} | 859 \LMHash{} |
860 A class has constructors, instance members and static members. The instance mem bers of a class are its instance methods, getters, setters and instance variable s. The static members of a class are its static methods, getters, setters and st atic variables. The members of a class are its static and instance members. | 860 A class has constructors, instance members and static members. The instance mem bers of a class are its instance methods, getters, setters and instance variable s. The static members of a class are its static methods, getters, setters and st atic variables. The members of a class are its static and instance members. |
861 | 861 |
862 % A class has a static scope and an instance scope. The enclosing scope of the s tatic scope of a non-generic class is the enclosing scope of the class declarati on. The enclosing scope of the static scope of a generic class is the type param eter scope (\ref{}) of the generic class declaration. | 862 A class has a static scope and an instance scope. The enclosing scope of the sta tic scope of a non-generic class is the enclosing scope of the class declaration . The enclosing scope of the static scope of a generic class is the type paramet er scope (\ref{generics}) of the generic class declaration. |
Lasse Reichstein Nielsen
2015/01/03 10:31:04
Could it be simpler to let all classes have a type
gbracha
2015/01/05 21:32:10
Done.
| |
863 %The enclosing scope of a class' instance scope is the class' static scope. | 863 The enclosing scope of a class' instance scope is the class' static scope. |
864 | 864 |
865 %The enclosing scope of an instance member declaration is the instance scope of the class in which it is declared. | 865 The enclosing scope of an instance member declaration is the instance scope of t he class in which it is declared. |
866 | 866 |
867 %The enclosing scope of a static member declaration is the static scope of the c lass in which it is declared. | 867 The enclosing scope of a static member declaration is the static scope of the cl ass in which it is declared. |
868 | 868 |
869 | 869 |
870 \LMHash{} | 870 \LMHash{} |
871 Every class has a single superclass except class \code{Object} which has no sup erclass. A class may implement a number of interfaces | 871 Every class has a single superclass except class \code{Object} which has no sup erclass. A class may implement a number of interfaces |
872 %, either | 872 %, either |
873 by declaring them in its implements clause (\ref{superinterfaces}). | 873 by declaring them in its implements clause (\ref{superinterfaces}). |
874 % or via interface injection declarations (\ref{interfaceInjection}) outside the class declaration | 874 % or via interface injection declarations (\ref{interfaceInjection}) outside the class declaration |
875 | 875 |
876 | 876 |
877 \LMHash{} | 877 \LMHash{} |
(...skipping 2400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3278 \LMHash{} | 3278 \LMHash{} |
3279 If $T$ is malformed or if $T$ is a type variable a dynamic error occurs. In che cked mode, if $T$ or any of its superclasses is malbounded a dynamic error occur s. | 3279 If $T$ is malformed or if $T$ is a type variable a dynamic error occurs. In che cked mode, if $T$ or any of its superclasses is malbounded a dynamic error occur s. |
3280 Otherwise, if $q$ is not defined or not accessible, a \code{NoSuchMethodError} is thrown. If $q$ has less than $n$ positional parameters or more than $n$ req uired parameters, or if $q$ lacks any of the keyword parameters $\{ x_{n+1}, \ld ots, x_{n+k}\}$ a \code{NoSuchMethodError} is thrown. | 3280 Otherwise, if $q$ is not defined or not accessible, a \code{NoSuchMethodError} is thrown. If $q$ has less than $n$ positional parameters or more than $n$ req uired parameters, or if $q$ lacks any of the keyword parameters $\{ x_{n+1}, \ld ots, x_{n+k}\}$ a \code{NoSuchMethodError} is thrown. |
3281 | 3281 |
3282 \LMHash{} | 3282 \LMHash{} |
3283 Otherwise, if $q$ is a generative constructor (\ref{generativeConstructors}), th en: | 3283 Otherwise, if $q$ is a generative constructor (\ref{generativeConstructors}), th en: |
3284 | 3284 |
3285 \commentary{Note that it this point we are assured that the number of actual typ e arguments match the number of formal type parameters.} | 3285 \commentary{Note that it this point we are assured that the number of actual typ e arguments match the number of formal type parameters.} |
3286 | 3286 |
3287 \LMHash{} | 3287 \LMHash{} |
3288 A fresh instance (\ref{generativeConstructors}), $i$, of class $R$ is allocated . For each instance variable $f$ of $i$, if the variable declaration of $f$ has an initializer expression $e_f$, then $e_f$ is evaluated to an object $o_f$ and $f$ is bound to $o_f$. Otherwise $f$ is bound to \NULL{}. | 3288 A fresh instance (\ref{generativeConstructors}), $i$, of class $R$ is allocated . For each instance variable $f$ of $i$, if the variable declaration of $f$ has an initializer expression $e_f$, then $e_f$ is evaluated, with the type paramet ers (if any) of $R$ bound to the actual type arguments $V_1, \ldots, V_l$, to an object $o_f$ and $f$ is bound to $o_f$. Otherwise $f$ is bound to \NULL{}. |
Lasse Reichstein Nielsen
2015/01/03 10:31:04
Still doesn't say in which dynamic scope the expre
gbracha
2015/01/05 21:32:10
All instance members are already said to be in the
| |
3289 | 3289 |
3290 \commentary{ | 3290 \commentary{ |
3291 Observe that \THIS{} is not in scope in $e_f$. Hence, the initialization cannot depend on other properties of the object being instantiated. | 3291 Observe that \THIS{} is not in scope in $e_f$. Hence, the initialization cannot depend on other properties of the object being instantiated. |
3292 } | 3292 } |
3293 | 3293 |
3294 \LMHash{} | 3294 \LMHash{} |
3295 Next, $q$ is executed with \THIS{} bound to $i$, the type parameters (if any) of $R$ bound to the actual type arguments $V_1, \ldots, V_l$ and the formal par ameter bindings that resulted from the evaluation of the argument list. The resu lt of the evaluation of $e$ is $i$. | 3295 Next, $q$ is executed with \THIS{} bound to $i$, the type parameters (if any) of $R$ bound to the actual type arguments $V_1, \ldots, V_l$ and the formal par ameter bindings that resulted from the evaluation of the argument list. The resu lt of the evaluation of $e$ is $i$. |
3296 | 3296 |
3297 \LMHash{} | 3297 \LMHash{} |
3298 Otherwise, $q$ is a factory constructor (\ref{factories}). Then: | 3298 Otherwise, $q$ is a factory constructor (\ref{factories}). Then: |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4006 \rationale{ | 4006 \rationale{ |
4007 The special treatment of equality in this case facilitates the use of extracted property functions in APIs where callbacks such as event listeners must often be registered and later unregistered. A common example is the DOM API in web brows ers. | 4007 The special treatment of equality in this case facilitates the use of extracted property functions in APIs where callbacks such as event listeners must often be registered and later unregistered. A common example is the DOM API in web brows ers. |
4008 } | 4008 } |
4009 | 4009 |
4010 | 4010 |
4011 | 4011 |
4012 | 4012 |
4013 \commentary{Observations: | 4013 \commentary{Observations: |
4014 \begin{enumerate} | 4014 \begin{enumerate} |
4015 \item One cannot closurize a getter or a setter. | 4015 \item One cannot closurize a getter or a setter. |
4016 \item One can tell whether one implemented a property via a method or via field/ getter, which means that one has to plan ahead as to what construct to use, and that choice is reflected in the interface of the class. | 4016 \item One can tell whether one implemented a property via a method or via a fiel d/getter, which means that one has to plan ahead as to what construct to use, an d that choice is reflected in the interface of the class. |
4017 \end{enumerate} | 4017 \end{enumerate} |
4018 } | 4018 } |
4019 | 4019 |
4020 | 4020 |
4021 | 4021 |
4022 \LMHash{} | 4022 \LMHash{} |
4023 The closurization of $\SUPER{}.m$ with respect to superclass $S$ is defined to b e equivalent to: | 4023 The closurization of $\SUPER{}.m$ with respect to superclass $S$ is defined to b e equivalent to: |
4024 | 4024 |
4025 \begin{itemize} | 4025 \begin{itemize} |
4026 %\item $(r_1, \ldots, r_n)\{\RETURN{}$ $o.m(r_1, \ldots, r_n);\}$ if $m$ has on ly required parameters $r_1, \ldots r_n$. | 4026 %\item $(r_1, \ldots, r_n)\{\RETURN{}$ $o.m(r_1, \ldots, r_n);\}$ if $m$ has on ly required parameters $r_1, \ldots r_n$. |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5125 \begin{grammar} | 5125 \begin{grammar} |
5126 {\bf forStatement:} | 5126 {\bf forStatement:} |
5127 \AWAIT? \FOR{} `(' forLoopParts `)' statement | 5127 \AWAIT? \FOR{} `(' forLoopParts `)' statement |
5128 . | 5128 . |
5129 | 5129 |
5130 {\bf forLoopParts:}forInitializerStatement expression? `{\escapegrammar ;}' expr essionList?; | 5130 {\bf forLoopParts:}forInitializerStatement expression? `{\escapegrammar ;}' expr essionList?; |
5131 declaredIdentifier \IN{} expression; | 5131 declaredIdentifier \IN{} expression; |
5132 identifier \IN{} expression | 5132 identifier \IN{} expression |
5133 . | 5133 . |
5134 | 5134 |
5135 {\bf forInitializerStatement:}localVariableDeclaration `{\escapegrammar ;}'; | 5135 {\bf forInitializerStatement:}localVariableDeclaration; |
5136 expression? `{\escapegrammar ;}' | 5136 expression? `{\escapegrammar ;}' |
5137 . | 5137 . |
5138 \end{grammar} | 5138 \end{grammar} |
5139 | 5139 |
5140 \LMHash{} | 5140 \LMHash{} |
5141 The for statement has three forms - the traditional for loop and two forms of t he for-in statement - synchronous and asynchronous. | 5141 The for statement has three forms - the traditional for loop and two forms of t he for-in statement - synchronous and asynchronous. |
5142 | 5142 |
5143 \subsubsection{For Loop} | 5143 \subsubsection{For Loop} |
5144 \LMLabel{forLoop} | 5144 \LMLabel{forLoop} |
5145 | 5145 |
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7155 Bitwise Or & $|$ & Left & 8\\ | 7155 Bitwise Or & $|$ & Left & 8\\ |
7156 \hline | 7156 \hline |
7157 Relational & $<$, $>$, $<=$, $>=$, \AS{}, \IS{}, \IS{}! & None & 7\\ | 7157 Relational & $<$, $>$, $<=$, $>=$, \AS{}, \IS{}, \IS{}! & None & 7\\ |
7158 \hline | 7158 \hline |
7159 Equality & ==, != & None & 6\\ | 7159 Equality & ==, != & None & 6\\ |
7160 \hline | 7160 \hline |
7161 Logical AND & \&\& & Left & 5\\ | 7161 Logical AND & \&\& & Left & 5\\ |
7162 \hline | 7162 \hline |
7163 Logical Or & $||$ & Left & 4\\ | 7163 Logical Or & $||$ & Left & 4\\ |
7164 \hline | 7164 \hline |
7165 Conditional & e1? e2: e3 & None & 3\\ | 7165 Conditional & e1? e2: e3 & Right & 3\\ |
Lasse Reichstein Nielsen
2015/01/03 10:31:04
So it's Right because
x ? y : z ? w : v
is
x ?
gbracha
2015/01/05 21:32:10
Yes
| |
7166 \hline | 7166 \hline |
7167 Cascade & .. & Left & 2\\ | 7167 Cascade & .. & Left & 2\\ |
7168 \hline | 7168 \hline |
7169 Assignment & =, *=, /=, +=, -= ,\&=, \^{}= etc. & Right & 1\\ | 7169 Assignment & =, *=, /=, +=, -= ,\&=, \^{}= etc. & Right & 1\\ |
7170 \hline | 7170 \hline |
7171 \end{tabular} | 7171 \end{tabular} |
7172 } | 7172 } |
7173 %\subsection{Glossary} | 7173 %\subsection{Glossary} |
7174 %\LMLabel{glossary} | 7174 %\LMLabel{glossary} |
7175 | 7175 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7337 | 7337 |
7338 The invariant that each normative paragraph is associated with a line | 7338 The invariant that each normative paragraph is associated with a line |
7339 containing the text \LMHash{} should be maintained. Extra occurrences | 7339 containing the text \LMHash{} should be maintained. Extra occurrences |
7340 of \LMHash{} can be added if needed, e.g., in order to make | 7340 of \LMHash{} can be added if needed, e.g., in order to make |
7341 individual \item{}s in itemized lists addressable. Each \LM.. command | 7341 individual \item{}s in itemized lists addressable. Each \LM.. command |
7342 must occur on a separate line. \LMHash{} must occur immediately | 7342 must occur on a separate line. \LMHash{} must occur immediately |
7343 before the associated paragraph, and \LMLabel must occur immediately | 7343 before the associated paragraph, and \LMLabel must occur immediately |
7344 after the associated \section{}, \subsection{} etc. | 7344 after the associated \section{}, \subsection{} etc. |
7345 | 7345 |
7346 ---------------------------------------------------------------------- | 7346 ---------------------------------------------------------------------- |
OLD | NEW |