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.3}} | 8 {\large Version 1.3}} |
9 %\author{The Dart Team} | 9 %\author{The Dart Team} |
10 \begin{document} | 10 \begin{document} |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 | 726 |
727 {\bf declaration:}constantConstructorSignature (redirection $|$ initializers)?; | 727 {\bf declaration:}constantConstructorSignature (redirection $|$ initializers)?; |
728 constructorSignature (redirection $|$ initializers)?; | 728 constructorSignature (redirection $|$ initializers)?; |
729 \EXTERNAL{} constantConstructorSignature; | 729 \EXTERNAL{} constantConstructorSignature; |
730 \EXTERNAL{} constructorSignature; | 730 \EXTERNAL{} constructorSignature; |
731 ((\EXTERNAL{} \STATIC{} ?))? getterSignature; | 731 ((\EXTERNAL{} \STATIC{} ?))? getterSignature; |
732 ((\EXTERNAL{} \STATIC{}?))? setterSignature; | 732 ((\EXTERNAL{} \STATIC{}?))? setterSignature; |
733 \EXTERNAL{}? operatorSignature; | 733 \EXTERNAL{}? operatorSignature; |
734 ((\EXTERNAL{} \STATIC{}?))? functionSignature; | 734 ((\EXTERNAL{} \STATIC{}?))? functionSignature; |
735 \STATIC{} (\FINAL{} $|$ \CONST{}) type? staticFinalDeclarationList; | 735 \STATIC{} (\FINAL{} $|$ \CONST{}) type? staticFinalDeclarationList; |
736 \CONST{} type? staticFinalDeclarationList; | 736 % \CONST{} type? staticFinalDeclarationList; |
737 \FINAL{} type? initializedIdentifierList; | 737 \FINAL{} type? initializedIdentifierList; |
738 \STATIC{}? (\VAR{} $|$ type) initializedIdentifierList | 738 \STATIC{}? (\VAR{} $|$ type) initializedIdentifierList |
739 . | 739 . |
740 | 740 |
741 {\bf staticFinalDeclarationList:} | 741 {\bf staticFinalDeclarationList:} |
742 staticFinalDeclaration (`,' staticFinalDeclaration)* | 742 staticFinalDeclaration (`,' staticFinalDeclaration)* |
743 . | 743 . |
744 | 744 |
745 {\bf staticFinalDeclaration:} | 745 {\bf staticFinalDeclaration:} |
746 identifier `=' expression | 746 identifier `=' expression |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1153 \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. | 1153 \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. |
1154 } | 1154 } |
1155 | 1155 |
1156 It is a compile-time error if a generative constructor of class \code{Object} includes a superinitializer. | 1156 It is a compile-time error if a generative constructor of class \code{Object} includes a superinitializer. |
1157 | 1157 |
1158 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$. | 1158 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$. |
1159 | 1159 |
1160 \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,. | 1160 \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,. |
1161 } | 1161 } |
1162 | 1162 |
1163 If $k$ is redirecting, then its redirect clause has the form | 1163 If $k$ is redirecting then its redirect clause has the form |
1164 | 1164 |
1165 \THIS{}$.g(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ | 1165 \THIS{}$.g(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ |
1166 | 1166 |
1167 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$. | 1167 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$. |
1168 | 1168 |
1169 Otherwise, execution proceeds as follows: | 1169 Otherwise, execution proceeds as follows: |
1170 | 1170 |
1171 %First, a fresh instance (\ref{generativeConstructors}) $i$ of the immediately e nclosing class is allocated. Next, the instance variable declarations of the im mediately enclosing class are visited in the order they appear in the program te xt. For each such declaration $d$, if $d$ has the form \code{$finalConstVarOrTy pe$ $v$ = $e$; } then the instance variable $v$ of $i$ is bound to the value of $e$ (which is necessarily a compile-time constant). | 1171 %First, a fresh instance (\ref{generativeConstructors}) $i$ of the immediately e nclosing class is allocated. Next, the instance variable declarations of the im mediately enclosing class are visited in the order they appear in the program te xt. For each such declaration $d$, if $d$ has the form \code{$finalConstVarOrTy pe$ $v$ = $e$; } then the instance variable $v$ of $i$ is bound to the value of $e$ (which is necessarily a compile-time constant). |
1172 %Next, a | 1172 %Next, a |
1173 Any initializing formals declared in $k$'s parameter list are executed in the or der they appear in the program text. | 1173 Any initializing formals declared in $k$'s parameter list are executed in the or der they appear in the program text. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 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. | 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. |
1342 | 1342 |
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. | 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. |
1344 | 1344 |
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. | 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. |
1346 | 1346 |
1347 \commentary{ | 1347 \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} | |
Lasse Reichstein Nielsen
2014/03/21 08:29:00
Long sentence. Add comma after "certain types"?
| |
1349 | |
1350 \begin{dartCode} | |
1351 \CLASS{} A \{ | |
1352 \FINAL{} m; | |
1353 \CONST{} A(this.m); | |
1354 \} | |
1355 \end{dartCode} | |
1356 | |
1357 \commentary{can be instantiated via \cd{\CONST{} A(\CONST []);}} | |
1358 | |
1359 | |
1360 | |
1361 \commentary{ | |
1348 The difference between a potentially constant expression and a compile-time cons tant expression (\ref{const}) deserves some explanation. | 1362 The difference between a potentially constant expression and a compile-time cons tant expression (\ref{const}) deserves some explanation. |
1349 | 1363 |
1350 The key issue is whether one treats the formal parameters of a constructor as co mpile-time constants. | 1364 The key issue is whether one treats the formal parameters of a constructor as co mpile-time constants. |
1351 | 1365 |
1352 If a constant constructor is invoked from a constant object expression, the actu al arguments will be required to be compile-time constants. Therefore, if we wer e assured that constant constructors were always invoked from constant object ex pressions, we could assume that the formal parameters of a constructor were comp ile-time constants. | 1366 If a constant constructor is invoked from a constant object expression, the actu al arguments will be required to be compile-time constants. Therefore, if we wer e assured that constant constructors were always invoked from constant object ex pressions, we could assume that the formal parameters of a constructor were comp ile-time constants. |
1353 | 1367 |
1354 However, constant constructors can also be invoked from ordinary instance creati on expressions (\ref{new}), and so the above assumption is not generally valid. | 1368 However, constant constructors can also be invoked from ordinary instance creati on expressions (\ref{new}), and so the above assumption is not generally valid. |
1355 | 1369 |
1356 Nevertheless, the use of the formal parameters of a constant constructor within the constructor is of considerable utility. The concept of potentially constant expressions is introduced to facilitate limited use of such formal parameters. S pecifically, we allow the usage of the formal parameters of a constant construct or for expressions that involve built-in operators, but not for constant objects , lists and maps. This allows for constructors such as: | 1370 Nevertheless, the use of the formal parameters of a constant constructor within the constructor is of considerable utility. The concept of potentially constant expressions is introduced to facilitate limited use of such formal parameters. S pecifically, we allow the usage of the formal parameters of a constant construct or for expressions that involve built-in operators, but not for constant objects , lists and maps. This allows for constructors such as: |
1357 } | 1371 } |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1886 \CLASS{} Sorter$<$T \EXTENDS{} Ordered$<$T$>>$ \{ | 1900 \CLASS{} Sorter$<$T \EXTENDS{} Ordered$<$T$>>$ \{ |
1887 sort(List$<$T$>$ l) {... l[n] $<$ l[n+1] ...} | 1901 sort(List$<$T$>$ l) {... l[n] $<$ l[n+1] ...} |
1888 \} | 1902 \} |
1889 | 1903 |
1890 \end{dartCode} | 1904 \end{dartCode} |
1891 | 1905 |
1892 \commentary{ | 1906 \commentary{ |
1893 Even where type parameters are in scope there are numerous restrictions at this time: | 1907 Even where type parameters are in scope there are numerous restrictions at this time: |
1894 \begin{itemize} | 1908 \begin{itemize} |
1895 \item A type parameter cannot be used to name a constructor in an instance creat ion expression (\ref{instanceCreation}). | 1909 \item A type parameter cannot be used to name a constructor in an instance creat ion expression (\ref{instanceCreation}). |
1896 \item A type parameter cannot be used as a superclass or superinterface (\ref{su perclasses}, \ref{superinterfaces}, \ref{interfaceSuperinterfaces}). | 1910 \item A type parameter cannot be used as a superclass or superinterface (\ref{su perclasses}, \ref{superinterfaces}, \ref{interfaceSuperinterfaces}). |
Lasse Reichstein Nielsen
2014/03/21 08:29:00
Or a mixin?
gbracha
2014/03/21 21:53:23
That is always implied. A mixin always acts as a s
| |
1911 \item A type parameter cannot be used as a generic. | |
Lasse Reichstein Nielsen
2014/03/21 08:29:00
A generic what? "Generic" is generally used as an
gbracha
2014/03/21 21:53:23
I'll add 'class" in the next rev.
| |
1897 \end{itemize} | 1912 \end{itemize} |
1898 | 1913 |
1899 The normative versions of these are given in the appropriate sections of this s pecification. Some of these restrictions may be lifted in the future. | 1914 The normative versions of these are given in the appropriate sections of this s pecification. Some of these restrictions may be lifted in the future. |
1900 } | 1915 } |
1901 | 1916 |
1902 %A generic has a type parameter scope. The enclosing scope of a type parameter s cope of a generic G is the enclosing scope of G. | 1917 %A generic has a type parameter scope. The enclosing scope of a type parameter s cope of a generic G is the enclosing scope of G. |
1903 | 1918 |
1904 | 1919 |
1905 %class T {...} | 1920 %class T {...} |
1906 | 1921 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2239 | 2254 |
2240 \commentary{ | 2255 \commentary{ |
2241 It follows that the two boolean literals are the only two instances of \code{boo l}. | 2256 It follows that the two boolean literals are the only two instances of \code{boo l}. |
2242 } | 2257 } |
2243 | 2258 |
2244 Invoking the getter \code{runtimeType} on a boolean literal returns the \code{Ty pe} object that is the value of the expression \code{bool}. The static type of a boolean literal is \code{bool}. | 2259 Invoking the getter \code{runtimeType} on a boolean literal returns the \code{Ty pe} object that is the value of the expression \code{bool}. The static type of a boolean literal is \code{bool}. |
2245 | 2260 |
2246 \subsubsection{Boolean Conversion} | 2261 \subsubsection{Boolean Conversion} |
2247 \label{booleanConversion} | 2262 \label{booleanConversion} |
2248 | 2263 |
2249 {\em Boolean conversion} maps any object $o$ into a boolean. Boolean conversion is defined by the function | 2264 {\em Boolean conversion} maps any object $o$ into a boolean. Boolean conversion is defined by the function application |
2250 | 2265 |
2251 \begin{dartCode} | 2266 \begin{dartCode} |
2252 (bool v)\{ | 2267 (bool v)\{ |
2253 \ASSERT{}(v != \NULL{}); | 2268 \ASSERT{}(v != \NULL{}); |
2254 % \IF{} (\NULL{} == v) \{ \THROW{} \NEW{} AssertionError('null is not a bo ol')\}; | 2269 % \IF{} (\NULL{} == v) \{ \THROW{} \NEW{} AssertionError('null is not a bo ol')\}; |
2255 \RETURN{} identical(v, \TRUE{}); | 2270 \RETURN{} identical(v, \TRUE{}); |
2256 \}(o) | 2271 \}(o) |
2257 \end{dartCode} | 2272 \end{dartCode} |
2258 | 2273 |
2259 \rationale{ | 2274 \rationale{ |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3505 If all of the following hold: | 3520 If all of the following hold: |
3506 \begin{itemize} | 3521 \begin{itemize} |
3507 \item $e_1$ shows that a variable $v$ has type $T$. | 3522 \item $e_1$ shows that a variable $v$ has type $T$. |
3508 \item $v$ is not potentially mutated in $e_2$ or within a closure. | 3523 \item $v$ is not potentially mutated in $e_2$ or within a closure. |
3509 \item If the variable $v$ is accessed by a closure in $e_2$ then the variable $v $ is not potentially mutated anywhere in the scope of $v$. | 3524 \item If the variable $v$ is accessed by a closure in $e_2$ then the variable $v $ is not potentially mutated anywhere in the scope of $v$. |
3510 \end{itemize} | 3525 \end{itemize} |
3511 | 3526 |
3512 then the type of $v$ is known to be $T$ in $e_2$. | 3527 then the type of $v$ is known to be $T$ in $e_2$. |
3513 | 3528 |
3514 | 3529 |
3515 It is a static type warning if the type of $e_1$ may not be assigned to \code{b ool}. The static type of $c$ is the least upper bound (\ref{leastUpperBounds}) of the static type of $e_2$ and the static type of $e_3$. | 3530 It is a static type warning if the static type of $e_1$ may not be assigned to \code{bool}. The static type of $c$ is the least upper bound (\ref{leastUpperBo unds}) of the static type of $e_2$ and the static type of $e_3$. |
3516 | 3531 |
3517 | 3532 |
3518 \subsection{ Logical Boolean Expressions} | 3533 \subsection{ Logical Boolean Expressions} |
3519 \label{logicalBooleanExpressions} | 3534 \label{logicalBooleanExpressions} |
3520 | 3535 |
3521 The logical boolean expressions combine boolean objects using the boolean conjun ction and disjunction operators. | 3536 The logical boolean expressions combine boolean objects using the boolean conjun ction and disjunction operators. |
3522 | 3537 |
3523 \begin{grammar} | 3538 \begin{grammar} |
3524 {\bf logicalOrExpression:} | 3539 {\bf logicalOrExpression:} |
3525 logicalAndExpression (`$||$' logicalAndExpression)* | 3540 logicalAndExpression (`$||$' logicalAndExpression)* |
(...skipping 21 matching lines...) Expand all Loading... | |
3547 \end{itemize} | 3562 \end{itemize} |
3548 | 3563 |
3549 Furthermore, if all of the following hold: | 3564 Furthermore, if all of the following hold: |
3550 \begin{itemize} | 3565 \begin{itemize} |
3551 \item $e_1$ shows that $v$ has type $T$. | 3566 \item $e_1$ shows that $v$ has type $T$. |
3552 \item $v$ is not mutated in either $e_1$, $e_2$ or within a closure. | 3567 \item $v$ is not mutated in either $e_1$, $e_2$ or within a closure. |
3553 \item If the variable $v$ is accessed by a closure in $e_2$ then the variable $v $ is not potentially mutated anywhere in the scope of $v$. | 3568 \item If the variable $v$ is accessed by a closure in $e_2$ then the variable $v $ is not potentially mutated anywhere in the scope of $v$. |
3554 \end{itemize} | 3569 \end{itemize} |
3555 then the type of $v$ is known to be $T$ in $e_2$. | 3570 then the type of $v$ is known to be $T$ in $e_2$. |
3556 | 3571 |
3557 The static type of a logical boolean expression is \code{bool}. | 3572 It is a static warning if the static types of both $e_1$ and $e_2$ may not be as signed to \cd{bool}. The static type of a logical boolean expression is \code{bo ol}. |
3558 | 3573 |
3559 | 3574 |
3560 \subsection{ Equality} | 3575 \subsection{ Equality} |
3561 \label{equality} | 3576 \label{equality} |
3562 | 3577 |
3563 Equality expressions test objects for equality. | 3578 Equality expressions test objects for equality. |
3564 | 3579 |
3565 \begin{grammar} | 3580 \begin{grammar} |
3566 {\bf equalityExpression:}relationalExpression (equalityOperator relationalExpres sion)?; | 3581 {\bf equalityExpression:}relationalExpression (equalityOperator relationalExpres sion)?; |
3567 \SUPER{} equalityOperator relationalExpression | 3582 \SUPER{} equalityOperator relationalExpression |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3899 {\bf IDENTIFIER\_NO\_DOLLAR:} | 3914 {\bf IDENTIFIER\_NO\_DOLLAR:} |
3900 IDENTIFIER\_START\_NO\_DOLLAR IDENTIFIER\_PART\_NO\_DOLLAR* | 3915 IDENTIFIER\_START\_NO\_DOLLAR IDENTIFIER\_PART\_NO\_DOLLAR* |
3901 . | 3916 . |
3902 | 3917 |
3903 {\bf IDENTIFIER:} | 3918 {\bf IDENTIFIER:} |
3904 IDENTIFIER\_START IDENTIFIER\_PART* | 3919 IDENTIFIER\_START IDENTIFIER\_PART* |
3905 . | 3920 . |
3906 | 3921 |
3907 {\bf BUILT\_IN\_IDENTIFIER:} \ABSTRACT{}; | 3922 {\bf BUILT\_IN\_IDENTIFIER:} \ABSTRACT{}; |
3908 \AS{}; | 3923 \AS{}; |
3909 % \ASSERT{}; | |
3910 \DEFERRED{}; | 3924 \DEFERRED{}; |
3911 \DYNAMIC{}; | 3925 \DYNAMIC{}; |
3912 \EXPORT{}; | 3926 \EXPORT{}; |
3913 \EXTERNAL{}; | 3927 \EXTERNAL{}; |
3914 \FACTORY{}; | 3928 \FACTORY{}; |
3915 \GET{}; | 3929 \GET{}; |
3916 \IMPLEMENTS{}; | 3930 \IMPLEMENTS{}; |
3917 \IMPORT{}; | 3931 \IMPORT{}; |
3918 \LIBRARY{}; | 3932 \LIBRARY{}; |
3919 \OPERATOR{}; | 3933 \OPERATOR{}; |
3920 \PART{}; | 3934 \PART{}; |
3921 \SET{}; | 3935 \SET{}; |
3922 \STATIC{}; | 3936 \STATIC{}; |
3923 \TYPEDEF{} | 3937 \TYPEDEF{} |
3924 . | 3938 . |
3925 | 3939 |
3926 {\bf IDENTIFIER\_START:}IDENTIFIER\_START\_NO\_DOLLAR; | 3940 {\bf IDENTIFIER\_START:}IDENTIFIER\_START\_NO\_DOLLAR; |
3927 '\$' | 3941 `\$' |
3928 . | 3942 . |
3929 | 3943 |
3930 {\bf IDENTIFIER\_START\_NO\_DOLLAR:}LETTER; | 3944 {\bf IDENTIFIER\_START\_NO\_DOLLAR:}LETTER; |
3931 '\_' | 3945 `\_' |
3932 . | 3946 . |
3933 | 3947 |
3934 {\bf IDENTIFIER\_PART\_NO\_DOLLAR:}IDENTIFIER\_START\_NO\_DOLLAR; | 3948 {\bf IDENTIFIER\_PART\_NO\_DOLLAR:}IDENTIFIER\_START\_NO\_DOLLAR; |
3935 DIGIT | 3949 DIGIT |
3936 . | 3950 . |
3937 | 3951 |
3938 | 3952 |
3939 {\bf IDENTIFIER\_PART:}IDENTIFIER\_START; | 3953 {\bf IDENTIFIER\_PART:}IDENTIFIER\_START; |
3940 DIGIT | 3954 DIGIT |
3941 . | 3955 . |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4326 The expression $[v^{\prime\prime}/v]e$ is evaluated, and the process recurses at step | 4340 The expression $[v^{\prime\prime}/v]e$ is evaluated, and the process recurses at step |
4327 \ref{beginFor}. | 4341 \ref{beginFor}. |
4328 \end{enumerate} | 4342 \end{enumerate} |
4329 | 4343 |
4330 \rationale{ | 4344 \rationale{ |
4331 The definition above is intended to prevent the common error where users create a closure inside a for loop, intending to close over the current binding of the loop variable, and find (usually after a painful process of debugging and learni ng) that all the created closures have captured the same value - the one current in the last iteration executed. | 4345 The definition above is intended to prevent the common error where users create a closure inside a for loop, intending to close over the current binding of the loop variable, and find (usually after a painful process of debugging and learni ng) that all the created closures have captured the same value - the one current in the last iteration executed. |
4332 | 4346 |
4333 Instead, each iteration has its own distinct variable. The first iteration uses the variable created by the initial declaration. The expression executed at the end of each iteration uses a fresh variable $v^{\prime\prime}$, bound to the va lue of the current iteration variable, and then modifies $v^{\prime\prime}$ as r equired for the next iteration. | 4347 Instead, each iteration has its own distinct variable. The first iteration uses the variable created by the initial declaration. The expression executed at the end of each iteration uses a fresh variable $v^{\prime\prime}$, bound to the va lue of the current iteration variable, and then modifies $v^{\prime\prime}$ as r equired for the next iteration. |
4334 } | 4348 } |
4335 | 4349 |
4336 | 4350 It is a static warning if the static type of $c$ may not be assigned to \cd{bool }. |
4337 | 4351 |
4338 %A for statement of the form \code{ \FOR{} ($d$ ; $c$; $e$) $s$} is equivalent t o the the following code: | 4352 %A for statement of the form \code{ \FOR{} ($d$ ; $c$; $e$) $s$} is equivalent t o the the following code: |
4339 | 4353 |
4340 %\code{ | 4354 %\code{ |
4341 %\{$d$; | 4355 %\{$d$; |
4342 %\WHILE{} ($c$) \{ | 4356 %\WHILE{} ($c$) \{ |
4343 % \{$s$\} | 4357 % \{$s$\} |
4344 % $e$; | 4358 % $e$; |
4345 %\}\} | 4359 %\}\} |
4346 %} | 4360 %} |
(...skipping 26 matching lines...) Expand all Loading... | |
4373 \begin{grammar} | 4387 \begin{grammar} |
4374 {\bf whileStatement:} | 4388 {\bf whileStatement:} |
4375 \WHILE{} `(' expression `)' statement % could do top level here, and in f or | 4389 \WHILE{} `(' expression `)' statement % could do top level here, and in f or |
4376 . | 4390 . |
4377 \end{grammar} | 4391 \end{grammar} |
4378 | 4392 |
4379 Execution of a while statement of the form \code{\WHILE{} ($e$) $s$;} proceeds as follows: | 4393 Execution of a while statement of the form \code{\WHILE{} ($e$) $s$;} proceeds as follows: |
4380 | 4394 |
4381 The expression $e$ is evaluated to an object $o$. Then, $o$ is subjected to boo lean conversion (\ref{booleanConversion}), producing an object $r$. If $r$ is \ TRUE{}, then the statement $\{s\}$ is executed and then the while statement is r e-executed recursively. If $r$ is \FALSE{}, execution of the while statement is complete. | 4395 The expression $e$ is evaluated to an object $o$. Then, $o$ is subjected to boo lean conversion (\ref{booleanConversion}), producing an object $r$. If $r$ is \ TRUE{}, then the statement $\{s\}$ is executed and then the while statement is r e-executed recursively. If $r$ is \FALSE{}, execution of the while statement is complete. |
4382 | 4396 |
4383 It is a static type warning if the type of $e$ may not be assigned to \code{bool }. | 4397 It is a static type warning if the static type of $e$ may not be assigned to \co de{bool}. |
4384 | 4398 |
4385 | 4399 |
4386 \subsection{Do} | 4400 \subsection{Do} |
4387 \label{do} | 4401 \label{do} |
4388 | 4402 |
4389 The do statement supports conditional iteration, where the condition is evaluate d after the loop. | 4403 The do statement supports conditional iteration, where the condition is evaluate d after the loop. |
4390 | 4404 |
4391 \begin{grammar} | 4405 \begin{grammar} |
4392 {\bf doStatement:} | 4406 {\bf doStatement:} |
4393 \DO{} statement \WHILE{} `(' expression `)' `{\escapegrammar ;}'% could do t op level here | 4407 \DO{} statement \WHILE{} `(' expression `)' `{\escapegrammar ;}'% could do t op level here |
4394 . | 4408 . |
4395 \end{grammar} | 4409 \end{grammar} |
4396 | 4410 |
4397 | 4411 |
4398 Execution of a do statement of the form \code{\DO{} $s$ \WHILE{} ($e$);} proceed s as follows: | 4412 Execution of a do statement of the form \code{\DO{} $s$ \WHILE{} ($e$);} proceed s as follows: |
4399 | 4413 |
4400 The statement $\{s\}$ is executed. Then, the expression $e$ is evaluated to an o bject $o$. Then, $o$ is subjected to boolean conversion (\ref{booleanConversion }), producing an object $r$. If $r$ is \FALSE{}, execution of the do statement i s complete. If $r$ is \TRUE{}, then the do statement is re-executed recursively. | 4414 The statement $\{s\}$ is executed. Then, the expression $e$ is evaluated to an o bject $o$. Then, $o$ is subjected to boolean conversion (\ref{booleanConversion }), producing an object $r$. If $r$ is \FALSE{}, execution of the do statement i s complete. If $r$ is \TRUE{}, then the do statement is re-executed recursively. |
4401 | 4415 |
4402 It is a static type warning if the type of $e$ may not be assigned to \code{bool }. | 4416 It is a static type warning if the static type of $e$ may not be assigned to \co de{bool}. |
4403 | 4417 |
4404 \subsection{Switch} | 4418 \subsection{Switch} |
4405 \label{switch} | 4419 \label{switch} |
4406 | 4420 |
4407 The {\em switch statement} supports dispatching control among a large number of cases. | 4421 The {\em switch statement} supports dispatching control among a large number of cases. |
4408 | 4422 |
4409 \begin{grammar} | 4423 \begin{grammar} |
4410 {\bf switchStatement:} | 4424 {\bf switchStatement:} |
4411 \SWITCH{} `(' expression `)' `\{' switchCase* defaultCase? `\}'% could do top level here and in cases | 4425 \SWITCH{} `(' expression `)' `\{' switchCase* defaultCase? `\}'% could do top level here and in cases |
4412 . | 4426 . |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4873 \begin{grammar} | 4887 \begin{grammar} |
4874 {\bf topLevelDefinition:}classDefinition; | 4888 {\bf topLevelDefinition:}classDefinition; |
4875 % classDefinitionOrInterfaceInjection; | 4889 % classDefinitionOrInterfaceInjection; |
4876 % interfaceDefinitionOrInterfaceInjection; | 4890 % interfaceDefinitionOrInterfaceInjection; |
4877 % mixinApplication; | 4891 % mixinApplication; |
4878 typeAlias; | 4892 typeAlias; |
4879 \EXTERNAL{}? functionSignature `{\escapegrammar ;}'; | 4893 \EXTERNAL{}? functionSignature `{\escapegrammar ;}'; |
4880 \EXTERNAL{}? getterSignature `{\escapegrammar ;}'; | 4894 \EXTERNAL{}? getterSignature `{\escapegrammar ;}'; |
4881 \EXTERNAL{}? setterSignature `{\escapegrammar ;}'; | 4895 \EXTERNAL{}? setterSignature `{\escapegrammar ;}'; |
4882 functionSignature functionBody; | 4896 functionSignature functionBody; |
4883 returnType? getOrSet identifier formalParameterList functionBody; | 4897 returnType? \GET{} identifier functionBody; |
4898 returnType? \SET{} identifier formalParameterList functionBody; | |
4884 (\FINAL{} $|$ \CONST{}) type? staticFinalDeclarationList `{\escapegrammar ;}'; | 4899 (\FINAL{} $|$ \CONST{}) type? staticFinalDeclarationList `{\escapegrammar ;}'; |
4885 variableDeclaration `{\escapegrammar ;}' | 4900 variableDeclaration `{\escapegrammar ;}' |
4886 . | 4901 . |
4887 | 4902 |
4888 {\bf getOrSet:} \GET{}; | 4903 {\bf getOrSet:} \GET{}; |
4889 \SET{} | 4904 \SET{} |
4890 . | 4905 . |
4891 | 4906 |
4892 % classDefinitionOrInterfaceInjection: | 4907 % classDefinitionOrInterfaceInjection: |
4893 % classDefinition; | 4908 % classDefinition; |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. | 5883 \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. |
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 | 5884 \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 |
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. | 5885 \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. |
5871 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E. | 5886 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E. |
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. | 5887 \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. |
5873 \end{itemize} | 5888 \end{itemize} |
5874 } | 5889 } |
5875 | 5890 |
5876 | 5891 |
5877 \end{document} | 5892 \end{document} |
OLD | NEW |