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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 whose execution sets the value of $v$ to the incoming argument $x$. | 516 whose execution sets the value of $v$ to the incoming argument $x$. |
517 | 517 |
518 | 518 |
519 \subsection{Evaluation of Implicit Variable Getters} | 519 \subsection{Evaluation of Implicit Variable Getters} |
520 \LMLabel{evaluationOfImplicitVariableGetters} | 520 \LMLabel{evaluationOfImplicitVariableGetters} |
521 | 521 |
522 \LMHash{} | 522 \LMHash{} |
523 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$. | 523 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$. |
524 If $d$ is a static or library variable then the implicit getter method of $v$ ex ecutes as follows: | 524 If $d$ is a static or library variable then the implicit getter method of $v$ ex ecutes as follows: |
525 \begin{itemize} | 525 \begin{itemize} |
526 \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$. | 526 \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$. |
Lasse Reichstein Nielsen
2015/01/12 15:32:41
Specify that the scope of evaluation of "e" is the
| |
527 \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. } | 527 \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. } |
528 Otherwise | 528 Otherwise |
529 \item {\bf Variable declaration without initializer}. The result of executing th e getter method is the value stored in $v$. | 529 \item {\bf Variable declaration without initializer}. The result of executing th e getter method is the value stored in $v$. |
530 \end{itemize} | 530 \end{itemize} |
531 | 531 |
532 | 532 |
533 | 533 |
534 | 534 |
535 | 535 |
536 \section{Functions} | 536 \section{Functions} |
(...skipping 214 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 several scopes: |
863 %The enclosing scope of a class' instance scope is the class' static scope. | 863 \begin{itemize} |
864 \item A {\em type-parameter scope}, which is empty if the class is not generic ( \ref{generics}). The enclosing scope of the static scope of the type parameter scope of a class is the enclosing scope of the class declaration. | |
Lasse Reichstein Nielsen
2015/01/12 15:32:41
Remove "the static scope of" here?
| |
865 \item A {\em static scope}. The enclosing scope of the static scope of a class is the type parameter scope (\ref{generics}) of the class. | |
Lasse Reichstein Nielsen
2015/01/12 15:32:41
"type-parameter" with hyphen (for consistency with
| |
866 \item An {\em instance scope}. | |
867 The enclosing scope of a class' instance scope is the class' static scope. | |
868 \end{itemize} | |
864 | 869 |
865 %The enclosing scope of an instance member declaration is the instance scope of the class in which it is declared. | 870 The enclosing scope of an instance member declaration is the instance scope of t he class in which it is declared. |
866 | 871 |
867 %The enclosing scope of a static member declaration is the static scope of the c lass in which it is declared. | 872 The enclosing scope of a static member declaration is the static scope of the cl ass in which it is declared. |
868 | 873 |
869 | 874 |
870 \LMHash{} | 875 \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 | 876 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 | 877 %, either |
873 by declaring them in its implements clause (\ref{superinterfaces}). | 878 by declaring them in its implements clause (\ref{superinterfaces}). |
874 % or via interface injection declarations (\ref{interfaceInjection}) outside the class declaration | 879 % or via interface injection declarations (\ref{interfaceInjection}) outside the class declaration |
875 | 880 |
876 | 881 |
877 \LMHash{} | 882 \LMHash{} |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1311 or a static warning occurs. It is a compile-time error if $k$'s initializer list contains an initializer for a variable that is not an instance variable declare d in the immediately surrounding class. | 1316 or a static warning occurs. It is a compile-time error if $k$'s initializer list contains an initializer for a variable that is not an instance variable declare d in the immediately surrounding class. |
1312 | 1317 |
1313 | 1318 |
1314 \commentary{The initializer list may of course contain an initializer for any instance variable declared by the immediately surrounding class, even if it is n ot final. | 1319 \commentary{The initializer list may of course contain an initializer for any instance variable declared by the immediately surrounding class, even if it is n ot final. |
1315 } | 1320 } |
1316 | 1321 |
1317 \LMHash{} | 1322 \LMHash{} |
1318 It is a compile-time error if a generative constructor of class \code{Object} includes a superinitializer. | 1323 It is a compile-time error if a generative constructor of class \code{Object} includes a superinitializer. |
1319 | 1324 |
1320 \LMHash{} | 1325 \LMHash{} |
1321 Execution of a generative constructor $k$ is always done with respect to a set o f bindings for its formal parameters and with \THIS{} bound to a fresh instance $i$ and the type parameters of the immediately enclosing class bound to a set o f actual type arguments $V_1, \ldots , V_m$. | 1326 Execution of a generative constructor $k$ is always done with respect to a set o f bindings for its formal parameters and with \THIS{} bound to a fresh instance $i$ and the type parameters of the immediately enclosing class bound to a set o f actual type arguments $V_1, \ldots , V_m$. |
Lasse Reichstein Nielsen
2015/01/12 15:32:41
Should it be said that the enclosing scope is the
| |
1322 | 1327 |
1323 \commentary{These bindings are usually determined by the instance creation expre ssion that invoked the constructor (directly or indirectly). However, they may a lso be determined by a reflective call,. | 1328 \commentary{These bindings are usually determined by the instance creation expre ssion that invoked the constructor (directly or indirectly). However, they may a lso be determined by a reflective call,. |
1324 } | 1329 } |
1325 | 1330 |
1326 \LMHash{} | 1331 \LMHash{} |
1327 If $k$ is redirecting then its redirect clause has the form | 1332 If $k$ is redirecting then its redirect clause has the form |
1328 | 1333 |
1329 \THIS{}$.g(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ | 1334 \THIS{}$.g(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ |
1330 | 1335 |
1331 where $g$ identifies another generative constructor of the immediately surround ing class. Then execution of $k$ proceeds by evaluating the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, and then executing $g$ with respect to the bindings resulting from the evaluation of $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ and with \THIS{} bound to $i$ and the type parameters of the immediately enclosing class bound to $V_1, \ ldots , V_m$. | 1336 where $g$ identifies another generative constructor of the immediately surround ing class. Then execution of $k$ proceeds by evaluating the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, and then executing $g$ with respect to the bindings resulting from the evaluation of $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ and with \THIS{} bound to $i$ and the type parameters of the immediately enclosing class bound to $V_1, \ ldots , V_m$. |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1700 \EXTENDS{} type | 1705 \EXTENDS{} type |
1701 . | 1706 . |
1702 \end{grammar} | 1707 \end{grammar} |
1703 | 1708 |
1704 %The superclass clause of a class C is processed within the enclosing scope of t he static scope of C. | 1709 %The superclass clause of a class C is processed within the enclosing scope of t he static scope of C. |
1705 %\commentary{ | 1710 %\commentary{ |
1706 %This means that in a generic class, the type parameters of the generic are avai lable in the superclass clause. | 1711 %This means that in a generic class, the type parameters of the generic are avai lable in the superclass clause. |
1707 %} | 1712 %} |
1708 | 1713 |
1709 \LMHash{} | 1714 \LMHash{} |
1715 The scope of the \EXTENDS{} and \WITH{} clauses of a class $C$ is the type-param eter scope of $C$. | |
1716 | |
1717 \LMHash{} | |
1710 %It is a compile-time error if the \EXTENDS{} clause of a class $C$ includes a type expression that does not denote a class available in the lexical scope of $ C$. | 1718 %It is a compile-time error if the \EXTENDS{} clause of a class $C$ includes a type expression that does not denote a class available in the lexical scope of $ C$. |
1711 It is a compile-time error if the \EXTENDS{} clause of a class $C$ specifies an enumerated type (\ref{enums}), a malformed type or a deferred type (\ref{stati cTypes}) as a superclass. | 1719 It is a compile-time error if the \EXTENDS{} clause of a class $C$ specifies an enumerated type (\ref{enums}), a malformed type or a deferred type (\ref{stati cTypes}) as a superclass. |
1712 % too strict? Do we e want extends List<Undeclared> to work as List<dynamic>? | 1720 % too strict? Do we e want extends List<Undeclared> to work as List<dynamic>? |
1713 | 1721 |
1714 \commentary{ The type parameters of a generic class are available in the lexical scope of the superclass clause, potentially shadowing classes in the surroundin g scope. The following code is therefore illegal and should cause a compile-time error: | 1722 \commentary{ The type parameters of a generic class are available in the lexical scope of the superclass clause, potentially shadowing classes in the surroundin g scope. The following code is therefore illegal and should cause a compile-time error: |
1715 } | 1723 } |
1716 | 1724 |
1717 \begin{dartCode} | 1725 \begin{dartCode} |
1718 class T \{\} | 1726 class T \{\} |
1719 | 1727 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1833 A class has a set of direct superinterfaces. This set includes the interface of its superclass and the interfaces specified in the the \IMPLEMENTS{} clause of the class. | 1841 A class has a set of direct superinterfaces. This set includes the interface of its superclass and the interfaces specified in the the \IMPLEMENTS{} clause of the class. |
1834 % and any superinterfaces specified by interface injection (\ref{interfaceInject ion}). \Q{The latter needs to be worded carefully - when do interface injection clauses execute and in what scope?} | 1842 % and any superinterfaces specified by interface injection (\ref{interfaceInject ion}). \Q{The latter needs to be worded carefully - when do interface injection clauses execute and in what scope?} |
1835 | 1843 |
1836 \begin{grammar} | 1844 \begin{grammar} |
1837 {\bf interfaces:} | 1845 {\bf interfaces:} |
1838 \IMPLEMENTS{} typeList | 1846 \IMPLEMENTS{} typeList |
1839 . | 1847 . |
1840 \end{grammar} | 1848 \end{grammar} |
1841 | 1849 |
1842 \LMHash{} | 1850 \LMHash{} |
1851 The scope of the \IMPLEMENTS{} clause of a class $C$ is the type-parameter scope of $C$. | |
1852 | |
1853 \LMHash{} | |
1843 It is a compile-time error if the \IMPLEMENTS{} clause of a class $C$ specifie s a type variable as a superinterface. It is a compile-time error if the \IMPL EMENTS{} clause of a class $C$ specifies an enumerated type (\ref{enums}), a ma lformed type or deferred type (\ref{staticTypes}) as a superinterface It is a c ompile-time error if the \IMPLEMENTS{} clause of a class $C$ specifies type \DYN AMIC{} as a superinterface. It is a compile-time error if the \IMPLEMENTS{} cl ause of a class $C$ specifies a type $T$ as a superinterface more than once. | 1854 It is a compile-time error if the \IMPLEMENTS{} clause of a class $C$ specifie s a type variable as a superinterface. It is a compile-time error if the \IMPL EMENTS{} clause of a class $C$ specifies an enumerated type (\ref{enums}), a ma lformed type or deferred type (\ref{staticTypes}) as a superinterface It is a c ompile-time error if the \IMPLEMENTS{} clause of a class $C$ specifies type \DYN AMIC{} as a superinterface. It is a compile-time error if the \IMPLEMENTS{} cl ause of a class $C$ specifies a type $T$ as a superinterface more than once. |
1844 It is a compile-time error if the superclass of a class $C$ is specified as a su perinterface of $C$. | 1855 It is a compile-time error if the superclass of a class $C$ is specified as a su perinterface of $C$. |
1845 | 1856 |
1846 \rationale{ | 1857 \rationale{ |
1847 One might argue that it is harmless to repeat a type in the superinterface list, so why make it an error? The issue is not so much that the situation described in program source is erroneous, but that it is pointless. As such, it is an indi cation that the programmer may very well have meant to say something else - and that is a mistake that should be called to her or his attention. Nevertheless, we could simply issue a warning; and perhaps we should and will. That said, prob lems like these are local and easily corrected on the spot, so we feel justified in taking a harder line. | 1858 One might argue that it is harmless to repeat a type in the superinterface list, so why make it an error? The issue is not so much that the situation described in program source is erroneous, but that it is pointless. As such, it is an indi cation that the programmer may very well have meant to say something else - and that is a mistake that should be called to her or his attention. Nevertheless, we could simply issue a warning; and perhaps we should and will. That said, prob lems like these are local and easily corrected on the spot, so we feel justified in taking a harder line. |
1848 } | 1859 } |
1849 | 1860 |
1850 \LMHash{} | 1861 \LMHash{} |
1851 It is a compile-time error if the interface of a class $C$ is a superinterface o f itself. | 1862 It is a compile-time error if the interface of a class $C$ is a superinterface o f itself. |
1852 | 1863 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2153 . | 2164 . |
2154 {\bf typeParameters:} | 2165 {\bf typeParameters:} |
2155 `<' typeParameter (`,' typeParameter)* `>' | 2166 `<' typeParameter (`,' typeParameter)* `>' |
2156 . | 2167 . |
2157 \end{grammar} | 2168 \end{grammar} |
2158 | 2169 |
2159 \LMHash{} | 2170 \LMHash{} |
2160 A type parameter $T$ may be suffixed with an \EXTENDS{} clause that specifies th e {\em upper bound} for $T$. If no \EXTENDS{} clause is present, the upper boun d is \code{Object}. It is a static type warning if a type parameter is a supert ype of its upper bound. The bounds of type variables are a form of type annotati on and have no effect on execution in production mode. | 2171 A type parameter $T$ may be suffixed with an \EXTENDS{} clause that specifies th e {\em upper bound} for $T$. If no \EXTENDS{} clause is present, the upper boun d is \code{Object}. It is a static type warning if a type parameter is a supert ype of its upper bound. The bounds of type variables are a form of type annotati on and have no effect on execution in production mode. |
2161 | 2172 |
2162 \LMHash{} | 2173 \LMHash{} |
2174 Type parameters are declared in the type-parameter scope of a class. | |
2163 The type parameters of a generic $G$ are in scope in the bounds of all of the ty pe parameters of $G$. The type parameters of a generic class declaration $G$ are also in scope in the \EXTENDS{} and \IMPLEMENTS{} clauses of $G$ (if these exis t) and in the body of $G$. However, a type parameter is considered to be a mal formed type when referenced by a static member. | 2175 The type parameters of a generic $G$ are in scope in the bounds of all of the ty pe parameters of $G$. The type parameters of a generic class declaration $G$ are also in scope in the \EXTENDS{} and \IMPLEMENTS{} clauses of $G$ (if these exis t) and in the body of $G$. However, a type parameter is considered to be a mal formed type when referenced by a static member. |
2164 | 2176 |
2165 \rationale{ | 2177 \rationale{ |
2166 The restriction is necessary since a type variable has no meaning in the context of a static member, because statics are shared among all instantiations of a ge neric. However, a type variable may be referenced from an instance initializer, even though \THIS{} is not available. | 2178 The restriction is necessary since a type variable has no meaning in the context of a static member, because statics are shared among all instantiations of a ge neric. However, a type variable may be referenced from an instance initializer, even though \THIS{} is not available. |
2167 } | 2179 } |
2168 | 2180 |
2169 \commentary{ | 2181 \commentary{ |
2170 Because type parameters are in scope in their bounds, we support F-bounded quant ification (if you don't know what that is, don't ask). This enables typechecking code such as: | 2182 Because type parameters are in scope in their bounds, we support F-bounded quant ification (if you don't know what that is, don't ask). This enables typechecking code such as: |
2171 } | 2183 } |
2172 | 2184 |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2680 | 2692 |
2681 \rationale{ which this prints 'A simple sum: 2 + 2 = 22' rather than 'A simple sum: 2 + 2 = 4'. | 2693 \rationale{ which this prints 'A simple sum: 2 + 2 = 22' rather than 'A simple sum: 2 + 2 = 4'. |
2682 However, the use the concatenation operation is still discouraged for efficienc y reasons. Instead, the recommended Dart idiom is to use string interpolation. | 2694 However, the use the concatenation operation is still discouraged for efficienc y reasons. Instead, the recommended Dart idiom is to use string interpolation. |
2683 } | 2695 } |
2684 | 2696 |
2685 \begin{dartCode} | 2697 \begin{dartCode} |
2686 print("A simple sum: 2 + 2 = \$\{2+2\}"); | 2698 print("A simple sum: 2 + 2 = \$\{2+2\}"); |
2687 \end{dartCode} | 2699 \end{dartCode} |
2688 | 2700 |
2689 | 2701 |
2690 \rationale{String interpolation work well for most cases. The main situation whe re it is not fully satisfactory is for string literals that are too large to fit on a line. Multiline strings can be useful, but in some cases, we want to visua lly align the code. This can be expressed by writing smaller strings separated b y whitespace, as shown here:} | 2702 \rationale{String interpolation works well for most cases. The main situation wh ere it is not fully satisfactory is for string literals that are too large to fi t on a line. Multiline strings can be useful, but in some cases, we want to visu ally align the code. This can be expressed by writing smaller strings separated by whitespace, as shown here:} |
2691 | 2703 |
2692 | 2704 |
2693 | 2705 |
2694 | 2706 |
2695 \begin{dartCode} | 2707 \begin{dartCode} |
2696 'Imagine this is a very long string that does not fit on a line. What shall we d o? ' | 2708 'Imagine this is a very long string that does not fit on a line. What shall we d o? ' |
2697 'Oh what shall we do? ' | 2709 'Oh what shall we do? ' |
2698 'We shall split it into pieces ' | 2710 'We shall split it into pieces ' |
2699 'like so'. | 2711 'like so'. |
2700 \end{dartCode} | 2712 \end{dartCode} |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3278 \LMHash{} | 3290 \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. | 3291 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. | 3292 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 | 3293 |
3282 \LMHash{} | 3294 \LMHash{} |
3283 Otherwise, if $q$ is a generative constructor (\ref{generativeConstructors}), th en: | 3295 Otherwise, if $q$ is a generative constructor (\ref{generativeConstructors}), th en: |
3284 | 3296 |
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.} | 3297 \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 | 3298 |
3287 \LMHash{} | 3299 \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{}. | 3300 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{}. |
3289 | 3301 |
3290 \commentary{ | 3302 \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. | 3303 Observe that \THIS{} is not in scope in $e_f$. Hence, the initialization cannot depend on other properties of the object being instantiated. |
3292 } | 3304 } |
3293 | 3305 |
3294 \LMHash{} | 3306 \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$. | 3307 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 | 3308 |
3297 \LMHash{} | 3309 \LMHash{} |
3298 Otherwise, $q$ is a factory constructor (\ref{factories}). Then: | 3310 Otherwise, $q$ is a factory constructor (\ref{factories}). Then: |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4006 \rationale{ | 4018 \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. | 4019 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 } | 4020 } |
4009 | 4021 |
4010 | 4022 |
4011 | 4023 |
4012 | 4024 |
4013 \commentary{Observations: | 4025 \commentary{Observations: |
4014 \begin{enumerate} | 4026 \begin{enumerate} |
4015 \item One cannot closurize a getter or a setter. | 4027 \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. | 4028 \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} | 4029 \end{enumerate} |
4018 } | 4030 } |
4019 | 4031 |
4020 | 4032 |
4021 | 4033 |
4022 \LMHash{} | 4034 \LMHash{} |
4023 The closurization of $\SUPER{}.m$ with respect to superclass $S$ is defined to b e equivalent to: | 4035 The closurization of $\SUPER{}.m$ with respect to superclass $S$ is defined to b e equivalent to: |
4024 | 4036 |
4025 \begin{itemize} | 4037 \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$. | 4038 %\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} | 5137 \begin{grammar} |
5126 {\bf forStatement:} | 5138 {\bf forStatement:} |
5127 \AWAIT? \FOR{} `(' forLoopParts `)' statement | 5139 \AWAIT? \FOR{} `(' forLoopParts `)' statement |
5128 . | 5140 . |
5129 | 5141 |
5130 {\bf forLoopParts:}forInitializerStatement expression? `{\escapegrammar ;}' expr essionList?; | 5142 {\bf forLoopParts:}forInitializerStatement expression? `{\escapegrammar ;}' expr essionList?; |
5131 declaredIdentifier \IN{} expression; | 5143 declaredIdentifier \IN{} expression; |
5132 identifier \IN{} expression | 5144 identifier \IN{} expression |
5133 . | 5145 . |
5134 | 5146 |
5135 {\bf forInitializerStatement:}localVariableDeclaration `{\escapegrammar ;}'; | 5147 {\bf forInitializerStatement:}localVariableDeclaration; |
5136 expression? `{\escapegrammar ;}' | 5148 expression? `{\escapegrammar ;}' |
5137 . | 5149 . |
5138 \end{grammar} | 5150 \end{grammar} |
5139 | 5151 |
5140 \LMHash{} | 5152 \LMHash{} |
5141 The for statement has three forms - the traditional for loop and two forms of t he for-in statement - synchronous and asynchronous. | 5153 The for statement has three forms - the traditional for loop and two forms of t he for-in statement - synchronous and asynchronous. |
5142 | 5154 |
5143 \subsubsection{For Loop} | 5155 \subsubsection{For Loop} |
5144 \LMLabel{forLoop} | 5156 \LMLabel{forLoop} |
5145 | 5157 |
(...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7155 Bitwise Or & $|$ & Left & 8\\ | 7167 Bitwise Or & $|$ & Left & 8\\ |
7156 \hline | 7168 \hline |
7157 Relational & $<$, $>$, $<=$, $>=$, \AS{}, \IS{}, \IS{}! & None & 7\\ | 7169 Relational & $<$, $>$, $<=$, $>=$, \AS{}, \IS{}, \IS{}! & None & 7\\ |
7158 \hline | 7170 \hline |
7159 Equality & ==, != & None & 6\\ | 7171 Equality & ==, != & None & 6\\ |
7160 \hline | 7172 \hline |
7161 Logical AND & \&\& & Left & 5\\ | 7173 Logical AND & \&\& & Left & 5\\ |
7162 \hline | 7174 \hline |
7163 Logical Or & $||$ & Left & 4\\ | 7175 Logical Or & $||$ & Left & 4\\ |
7164 \hline | 7176 \hline |
7165 Conditional & e1? e2: e3 & None & 3\\ | 7177 Conditional & e1? e2: e3 & Right & 3\\ |
7166 \hline | 7178 \hline |
7167 Cascade & .. & Left & 2\\ | 7179 Cascade & .. & Left & 2\\ |
7168 \hline | 7180 \hline |
7169 Assignment & =, *=, /=, +=, -= ,\&=, \^{}= etc. & Right & 1\\ | 7181 Assignment & =, *=, /=, +=, -= ,\&=, \^{}= etc. & Right & 1\\ |
7170 \hline | 7182 \hline |
7171 \end{tabular} | 7183 \end{tabular} |
7172 } | 7184 } |
7173 %\subsection{Glossary} | 7185 %\subsection{Glossary} |
7174 %\LMLabel{glossary} | 7186 %\LMLabel{glossary} |
7175 | 7187 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7337 | 7349 |
7338 The invariant that each normative paragraph is associated with a line | 7350 The invariant that each normative paragraph is associated with a line |
7339 containing the text \LMHash{} should be maintained. Extra occurrences | 7351 containing the text \LMHash{} should be maintained. Extra occurrences |
7340 of \LMHash{} can be added if needed, e.g., in order to make | 7352 of \LMHash{} can be added if needed, e.g., in order to make |
7341 individual \item{}s in itemized lists addressable. Each \LM.. command | 7353 individual \item{}s in itemized lists addressable. Each \LM.. command |
7342 must occur on a separate line. \LMHash{} must occur immediately | 7354 must occur on a separate line. \LMHash{} must occur immediately |
7343 before the associated paragraph, and \LMLabel must occur immediately | 7355 before the associated paragraph, and \LMLabel must occur immediately |
7344 after the associated \section{}, \subsection{} etc. | 7356 after the associated \section{}, \subsection{} etc. |
7345 | 7357 |
7346 ---------------------------------------------------------------------- | 7358 ---------------------------------------------------------------------- |
OLD | NEW |