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 (4th edition draft)\\ | 10 (4th edition draft)\\ |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 %\end{grammar} | 727 %\end{grammar} |
728 | 728 |
729 \subsubsection{Optional Formals} | 729 \subsubsection{Optional Formals} |
730 \LMLabel{optionalFormals} | 730 \LMLabel{optionalFormals} |
731 | 731 |
732 \LMHash{} | 732 \LMHash{} |
733 Optional parameters may be specified and provided with default values. | 733 Optional parameters may be specified and provided with default values. |
734 | 734 |
735 \begin{grammar} | 735 \begin{grammar} |
736 {\bf defaultFormalParameter:} | 736 {\bf defaultFormalParameter:} |
737 normalFormalParameter ('=' expression)? | 737 normalFormalParameter (`=' expression)? |
738 . | 738 . |
739 | 739 |
740 {\bf defaultNamedParameter:} | 740 {\bf defaultNamedParameter:} |
741 normalFormalParameter ( `{\escapegrammar :}' expression)? | 741 normalFormalParameter ( `{\escapegrammar :}' expression)? |
742 . | 742 . |
743 \end{grammar} | 743 \end{grammar} |
744 | 744 |
745 \LMHash{} | 745 \LMHash{} |
746 It is a compile-time error if the default value of an optional parameter is not a compile-time constant (\ref{constants}). If no default is explicitly specified for an optional parameter an implicit default of \NULL{} is provided. | 746 It is a compile-time error if the default value of an optional parameter is not a compile-time constant (\ref{constants}). If no default is explicitly specified for an optional parameter an implicit default of \NULL{} is provided. |
747 | 747 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
828 \STATIC{}? functionSignature; | 828 \STATIC{}? functionSignature; |
829 \STATIC{}? getterSignature; | 829 \STATIC{}? getterSignature; |
830 \STATIC{}? setterSignature; | 830 \STATIC{}? setterSignature; |
831 operatorSignature | 831 operatorSignature |
832 . | 832 . |
833 | 833 |
834 {\bf declaration:}constantConstructorSignature (redirection $|$ initializers)?; | 834 {\bf declaration:}constantConstructorSignature (redirection $|$ initializers)?; |
835 constructorSignature (redirection $|$ initializers)?; | 835 constructorSignature (redirection $|$ initializers)?; |
836 \EXTERNAL{} constantConstructorSignature; | 836 \EXTERNAL{} constantConstructorSignature; |
837 \EXTERNAL{} constructorSignature; | 837 \EXTERNAL{} constructorSignature; |
838 ((\EXTERNAL{} \STATIC{} ?))? getterSignature; | 838 (\EXTERNAL{} \STATIC{}?)? getterSignature; |
839 ((\EXTERNAL{} \STATIC{}?))? setterSignature; | 839 (\EXTERNAL{} \STATIC{}?)? setterSignature; |
840 \EXTERNAL{}? operatorSignature; | 840 \EXTERNAL{}? operatorSignature; |
841 ((\EXTERNAL{} \STATIC{}?))? functionSignature; | 841 (\EXTERNAL{} \STATIC{}?)? functionSignature; |
842 \STATIC{} (\FINAL{} $|$ \CONST{}) type? staticFinalDeclarationList; | 842 \STATIC{} (\FINAL{} $|$ \CONST{}) type? staticFinalDeclarationList; |
843 % \CONST{} type? staticFinalDeclarationList; | 843 % \CONST{} type? staticFinalDeclarationList; |
844 \FINAL{} type? initializedIdentifierList; | 844 \FINAL{} type? initializedIdentifierList; |
845 \STATIC{}? (\VAR{} $|$ type) initializedIdentifierList | 845 \STATIC{}? (\VAR{} $|$ type) initializedIdentifierList |
846 . | 846 . |
847 | 847 |
848 {\bf staticFinalDeclarationList:} | 848 {\bf staticFinalDeclarationList:} |
849 staticFinalDeclaration (`,' staticFinalDeclaration)* | 849 staticFinalDeclaration (`,' staticFinalDeclaration)* |
850 . | 850 . |
851 | 851 |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1588 \commentary{ | 1588 \commentary{ |
1589 The assignment to \code{x} is allowed under the assumption that \code{q} is a co mpile-time constant (even though \code{q} is not, in general a compile-time cons tant). The assignment to \code{y} is similar, but raises additional questions. In this case, the superexpression of \code{p} is \code{p + 100}, and it requires that \code{p} be a numeric compile-time constant for the entire expression to b e considered constant. The wording of the specification allows us to assume tha t \code{p} evaluates to an integer. A similar argument holds for \code{p} and \c ode{q} in the assignment to \code{z}. | 1589 The assignment to \code{x} is allowed under the assumption that \code{q} is a co mpile-time constant (even though \code{q} is not, in general a compile-time cons tant). The assignment to \code{y} is similar, but raises additional questions. In this case, the superexpression of \code{p} is \code{p + 100}, and it requires that \code{p} be a numeric compile-time constant for the entire expression to b e considered constant. The wording of the specification allows us to assume tha t \code{p} evaluates to an integer. A similar argument holds for \code{p} and \c ode{q} in the assignment to \code{z}. |
1590 | 1590 |
1591 However, the following constructors are disallowed: | 1591 However, the following constructors are disallowed: |
1592 } | 1592 } |
1593 | 1593 |
1594 \begin{dartCode} | 1594 \begin{dartCode} |
1595 \CLASS{} D \{ | 1595 \CLASS{} D \{ |
1596 \FINAL{} w; | 1596 \FINAL{} w; |
1597 \CONST{} D.makeList(p): w = \CONST{} [p]; // compile-time error | 1597 \CONST{} D.makeList(p): w = \CONST{} [p]; // compile-time error |
1598 \CONST{} D.makeMap(p): w = \CONST{} \{``help'': q\}; // compile-time error | 1598 \CONST{} D.makeMap(p): w = \CONST{} \{"help": q\}; // compile-time error |
gbracha
2015/12/21 19:06:53
No, this comes out wrong/ Some of these changes a
Patrice Chalin
2015/12/22 05:21:06
I guess that you know that in several other dartCo
| |
1599 \CONST{} D.makeC(p): w = \CONST{} C(p, 12); // compile-time error | 1599 \CONST{} D.makeC(p): w = \CONST{} C(p, 12); // compile-time error |
1600 \} | 1600 \} |
1601 \end{dartCode} | 1601 \end{dartCode} |
1602 | 1602 |
1603 \commentary{ | 1603 \commentary{ |
1604 The problem is not that the assignments to \code{w} are not potentially constant ; they are. However, all these run afoul of the rules for constant lists (\ref{ lists}), maps (\ref{maps}) and objects (\ref{const}), all of which independently require their subexpressions to be constant expressions. | 1604 The problem is not that the assignments to \code{w} are not potentially constant ; they are. However, all these run afoul of the rules for constant lists (\ref{ lists}), maps (\ref{maps}) and objects (\ref{const}), all of which independently require their subexpressions to be constant expressions. |
1605 } | 1605 } |
1606 | 1606 |
1607 \rationale{ | 1607 \rationale{ |
1608 All of the illegal constructors of \code{D} above could not be sensibly invoked via \NEW{}, because an expression that must be constant cannot depend on a forma l parameter, which may or may not be constant. In contrast, the legal examples m ake sense regardless of whether the constructor is invoked via \CONST{} or via \ NEW{}. | 1608 All of the illegal constructors of \code{D} above could not be sensibly invoked via \NEW{}, because an expression that must be constant cannot depend on a forma l parameter, which may or may not be constant. In contrast, the legal examples m ake sense regardless of whether the constructor is invoked via \CONST{} or via \ NEW{}. |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2526 . | 2526 . |
2527 \end{grammar} | 2527 \end{grammar} |
2528 | 2528 |
2529 \LMHash{} | 2529 \LMHash{} |
2530 The null object is the sole instance of the built-in class \code{Null}. Attempti ng to instantiate \code{Null} causes a run-time error. It is a compile-time erro r for a class to attempt to extend, mix in or implement \code{Null}. | 2530 The null object is the sole instance of the built-in class \code{Null}. Attempti ng to instantiate \code{Null} causes a run-time error. It is a compile-time erro r for a class to attempt to extend, mix in or implement \code{Null}. |
2531 Invoking a method on \NULL{} yields a \code{NoSuchMethodError} unless the metho d is explicitly implemented by class \code{Null}. | 2531 Invoking a method on \NULL{} yields a \code{NoSuchMethodError} unless the metho d is explicitly implemented by class \code{Null}. |
2532 | 2532 |
2533 \LMHash{} | 2533 \LMHash{} |
2534 The static type of \NULL{} is $\bot$. | 2534 The static type of \NULL{} is $\bot$. |
2535 | 2535 |
2536 \rationale{The decision to use $\bot$ instead of \code{Null} allows \NULL{} to b e be assigned everywhere without complaint by the static checker. | 2536 \rationale{The decision to use $\bot$ instead of \code{Null} allows \NULL{} to b e assigned everywhere without complaint by the static checker. |
2537 } | 2537 } |
2538 | 2538 |
2539 | 2539 |
2540 \subsection{Numbers} | 2540 \subsection{Numbers} |
2541 \LMLabel{numbers} | 2541 \LMLabel{numbers} |
2542 | 2542 |
2543 \LMHash{} | 2543 \LMHash{} |
2544 A {\em numeric literal} is either a decimal or hexadecimal integer of arbitrary size, or a decimal double. | 2544 A {\em numeric literal} is either a decimal or hexadecimal integer of arbitrary size, or a decimal double. |
2545 | 2545 |
2546 \begin{grammar} | 2546 \begin{grammar} |
2547 {\bf numericLiteral:}NUMBER; | 2547 {\bf numericLiteral:}NUMBER; |
2548 HEX\_NUMBER | 2548 HEX\_NUMBER |
2549 . | 2549 . |
2550 | 2550 |
2551 {\bf NUMBER:} DIGIT+ (`{\escapegrammar.}' DIGIT+)? EXPONENT?; | 2551 {\bf NUMBER:} DIGIT+ (`{\escapegrammar.}' DIGIT+)? EXPONENT?; |
2552 {`\escapegrammar .}' DIGIT+ EXPONENT? | 2552 `{\escapegrammar .}' DIGIT+ EXPONENT? |
2553 . | 2553 . |
2554 | 2554 |
2555 {\bf EXPONENT:} | 2555 {\bf EXPONENT:} |
2556 (`e' $|$ `E') ('+' $|$ `-`)? DIGIT+ | 2556 (`e' $|$ `E') (`+' $|$ `-')? DIGIT+ |
2557 . | 2557 . |
2558 | 2558 |
2559 {\bf HEX\_NUMBER:}`0x' HEX\_DIGIT+; | 2559 {\bf HEX\_NUMBER:}`0x' HEX\_DIGIT+; |
2560 `0X' HEX\_DIGIT+ | 2560 `0X' HEX\_DIGIT+ |
2561 . | 2561 . |
2562 | 2562 |
2563 {\bf HEX\_DIGIT:}`a'{\escapegrammar ..}'f'; | 2563 {\bf HEX\_DIGIT:}`a'{\escapegrammar ..}`f'; |
2564 `A'{\escapegrammar ..}'F'; | 2564 `A'{\escapegrammar ..}`F'; |
2565 DIGIT | 2565 DIGIT |
2566 . | 2566 . |
2567 \end{grammar} | 2567 \end{grammar} |
2568 | 2568 |
2569 \LMHash{} | 2569 \LMHash{} |
2570 If a numeric literal begins with the prefix `0x' or `0X', it denotes the hexadec imal integer represented by the part of the literal following `0x' (respectively `0X'). Otherwise, if the numeric literal does not include a decimal point it d enotes a decimal integer. Otherwise, the numeric literal denotes a 64 bit doub le precision floating point number as specified by the IEEE 754 standard. | 2570 If a numeric literal begins with the prefix `0x' or `0X', it denotes the hexadec imal integer represented by the part of the literal following `0x' (respectively `0X'). Otherwise, if the numeric literal does not include a decimal point it d enotes a decimal integer. Otherwise, the numeric literal denotes a 64 bit doub le precision floating point number as specified by the IEEE 754 standard. |
2571 | 2571 |
2572 \LMHash{} | 2572 \LMHash{} |
2573 In principle, the range of integers supported by a Dart implementations is unlim ited. In practice, it is limited by available memory. Implementations may also b e limited by other considerations. | 2573 In principle, the range of integers supported by a Dart implementations is unlim ited. In practice, it is limited by available memory. Implementations may also b e limited by other considerations. |
2574 | 2574 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2839 | 2839 |
2840 \LMHash{} | 2840 \LMHash{} |
2841 A {\em symbol literal} denotes the name of a declaration in a Dart program. | 2841 A {\em symbol literal} denotes the name of a declaration in a Dart program. |
2842 | 2842 |
2843 \begin{grammar} | 2843 \begin{grammar} |
2844 {\bf symbolLiteral:} | 2844 {\bf symbolLiteral:} |
2845 `\#' (operator $|$ (identifier (`{\escapegrammar .}' identifier)*)) . | 2845 `\#' (operator $|$ (identifier (`{\escapegrammar .}' identifier)*)) . |
2846 \end{grammar} | 2846 \end{grammar} |
2847 | 2847 |
2848 \LMHash{} | 2848 \LMHash{} |
2849 A symbol literal \code{\#id} where \code{id} does not begin with an underscore ( '\code{\_}') is equivalent to the expression \code{\CONST{} Symbol('id')}. | 2849 A symbol literal \code{\#id} where \code{id} does not begin with an underscore ( `\code{\_}') is equivalent to the expression \code{\CONST{} Symbol('id')}. |
2850 | 2850 |
2851 \LMHash{} | 2851 \LMHash{} |
2852 A symbol literal \code{\#\_id} evaluates to the object that would be returned by the call \code{mirror.getPrivateSymbol('id')} where mirror is an instance of th e class \code{LibraryMirror} defined in the library \code{dart:mirrors}, reflect ing the current library. | 2852 A symbol literal \code{\#\_id} evaluates to the object that would be returned by the call \code{mirror.getPrivateSymbol('id')} where mirror is an instance of th e class \code{LibraryMirror} defined in the library \code{dart:mirrors}, reflect ing the current library. |
2853 | 2853 |
2854 \rationale{ | 2854 \rationale{ |
2855 One may well ask what is the motivation for introducing literal symbols? In some languages, symbols are canonicalized whereas strings are not. However literal s trings are already canonicalized in Dart. Symbols are slightly easier to type c ompared to strings and their use can become strangely addictive, but this is not nearly sufficient justification for adding a literal form to the language. The primary motivation is related to the use of reflection and a web specific practi ce known as minification. | 2855 One may well ask what is the motivation for introducing literal symbols? In some languages, symbols are canonicalized whereas strings are not. However literal s trings are already canonicalized in Dart. Symbols are slightly easier to type c ompared to strings and their use can become strangely addictive, but this is not nearly sufficient justification for adding a literal form to the language. The primary motivation is related to the use of reflection and a web specific practi ce known as minification. |
2856 | 2856 |
2857 Minification compresses identifiers consistently throughout a program in order t o reduce download size. This practice poses difficulties for reflective program s that refer to program declarations via strings. A string will refer to an iden tifier in the source, but the identifier will no longer be used in the minified code, and reflective code using these would fail. Therefore, Dart reflection us es objects of type \code{Symbol} rather than strings. Instances of \code{Symbol } are guaranteed to be stable with repeat to minification. Providing a literal f orm for symbols makes reflective code easier to read and write. The fact that sy mbols are easy to type and can often act as convenient substitutes for enums are secondary benefits. | 2857 Minification compresses identifiers consistently throughout a program in order t o reduce download size. This practice poses difficulties for reflective program s that refer to program declarations via strings. A string will refer to an iden tifier in the source, but the identifier will no longer be used in the minified code, and reflective code using these would fail. Therefore, Dart reflection us es objects of type \code{Symbol} rather than strings. Instances of \code{Symbol } are guaranteed to be stable with repeat to minification. Providing a literal f orm for symbols makes reflective code easier to read and write. The fact that sy mbols are easy to type and can often act as convenient substitutes for enums are secondary benefits. |
2858 } | 2858 } |
2859 | 2859 |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3475 \CONST{} IntPair(\THIS{}.x, \THIS{}.y); | 3475 \CONST{} IntPair(\THIS{}.x, \THIS{}.y); |
3476 \FINAL{} int x; | 3476 \FINAL{} int x; |
3477 \FINAL{} int y; | 3477 \FINAL{} int y; |
3478 \OPERATOR *(v) $=>$ \NEW{} IntPair(x*v, y*v); | 3478 \OPERATOR *(v) $=>$ \NEW{} IntPair(x*v, y*v); |
3479 \} | 3479 \} |
3480 | 3480 |
3481 \CONST{} A(\CONST{} IntPair(1,2)); // compile-time error: illegal in a subtler w ay | 3481 \CONST{} A(\CONST{} IntPair(1,2)); // compile-time error: illegal in a subtler w ay |
3482 \end{dartCode} | 3482 \end{dartCode} |
3483 | 3483 |
3484 \commentary{ | 3484 \commentary{ |
3485 Due to the rules governing constant constructors, evaluating the constructor \co de{A()} with the argument \code{''x''} or the argument \code{\CONST{} IntPair(1, 2)} would cause it to throw an exception, resulting in a compile-time error. | 3485 Due to the rules governing constant constructors, evaluating the constructor \co de{A()} with the argument \code{"x"} or the argument \code{\CONST{} IntPair(1, 2 )} would cause it to throw an exception, resulting in a compile-time error. |
3486 } | 3486 } |
3487 | 3487 |
3488 | 3488 |
3489 \LMHash{} | 3489 \LMHash{} |
3490 Given an instance creation expression of the form \CONST{} $q(a_1, \ldots , a_n) $ it is a static warning if $q$ is a constructor of an abstract class (\ref{abs tractInstanceMembers}) but $q$ is not a factory constructor. | 3490 Given an instance creation expression of the form \CONST{} $q(a_1, \ldots , a_n) $ it is a static warning if $q$ is a constructor of an abstract class (\ref{abs tractInstanceMembers}) but $q$ is not a factory constructor. |
3491 | 3491 |
3492 | 3492 |
3493 \subsection{ Spawning an Isolate} | 3493 \subsection{ Spawning an Isolate} |
3494 \LMLabel{spawningAnIsolate} | 3494 \LMLabel{spawningAnIsolate} |
3495 | 3495 |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4417 | 4417 |
4418 % add local functions per bug 23218 | 4418 % add local functions per bug 23218 |
4419 | 4419 |
4420 \LMHash{} | 4420 \LMHash{} |
4421 If $d$ is the declaration of a library variable, top level getter or top level s etter, the expression $e$ is evaluated to an object $o$. Then the setter $v=$ is invoked with its formal parameter bound to $o$. The value of the assignment exp ression is $o$. | 4421 If $d$ is the declaration of a library variable, top level getter or top level s etter, the expression $e$ is evaluated to an object $o$. Then the setter $v=$ is invoked with its formal parameter bound to $o$. The value of the assignment exp ression is $o$. |
4422 | 4422 |
4423 \LMHash{} | 4423 \LMHash{} |
4424 Otherwise, if $d$ is the declaration of a static variable, static getter or stat ic setter in class $C$, then the assignment is equivalent to the assignment \cod e{$C.v$ = $e$}. | 4424 Otherwise, if $d$ is the declaration of a static variable, static getter or stat ic setter in class $C$, then the assignment is equivalent to the assignment \cod e{$C.v$ = $e$}. |
4425 | 4425 |
4426 \LMHash{} | 4426 \LMHash{} |
4427 Otherwise, If $a$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $a$ causes $ e$ to be evaluated, after which a \code{NoSuchMethodError} is thrown. | 4427 Otherwise, if $a$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $a$ causes $e $ to be evaluated, after which a \code{NoSuchMethodError} is thrown. |
4428 | 4428 |
4429 \LMHash{} | 4429 \LMHash{} |
4430 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. | 4430 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. |
4431 | 4431 |
4432 \LMHash{} | 4432 \LMHash{} |
4433 In checked mode, it is a dynamic type error if $o$ is not \NULL{} and the interf ace of the class of $o$ is not a subtype of the actual type (\ref{actualTypeOfAD eclaration}) of $v$. | 4433 In checked mode, it is a dynamic type error if $o$ is not \NULL{} and the interf ace of the class of $o$ is not a subtype of the actual type (\ref{actualTypeOfAD eclaration}) of $v$. |
4434 | 4434 |
4435 \LMHash{} | 4435 \LMHash{} |
4436 It is a static type warning if the static type of $e$ may not be assigned to the static type of $v$. The static type of the expression $v$ \code{=} $e$ is the s tatic type of $e$. | 4436 It is a static type warning if the static type of $e$ may not be assigned to the static type of $v$. The static type of the expression $v$ \code{=} $e$ is the s tatic type of $e$. |
4437 | 4437 |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5261 | 5261 |
5262 \LMHash{} | 5262 \LMHash{} |
5263 Evaluation of an identifier expression $e$ of the form $id$ proceeds as follows: | 5263 Evaluation of an identifier expression $e$ of the form $id$ proceeds as follows: |
5264 | 5264 |
5265 | 5265 |
5266 \LMHash{} | 5266 \LMHash{} |
5267 Let $d$ be the innermost declaration in the enclosing lexical scope whose name i s $id$ or $id=$. If no such declaration exists in the lexical scope, let $d$ be the declaration of the inherited member named $id$ if it exists. | 5267 Let $d$ be the innermost declaration in the enclosing lexical scope whose name i s $id$ or $id=$. If no such declaration exists in the lexical scope, let $d$ be the declaration of the inherited member named $id$ if it exists. |
5268 %If no such member exists, let $d$ be the declaration of the static member name $id$ declared in a superclass of the current class, if it exists. | 5268 %If no such member exists, let $d$ be the declaration of the static member name $id$ declared in a superclass of the current class, if it exists. |
5269 | 5269 |
5270 \begin{itemize} | 5270 \begin{itemize} |
5271 \item if $d$ is a prefix $p$, a compile-time error occurs unless the token immed iately following $d$ is \code{'.'}. | 5271 \item if $d$ is a prefix $p$, a compile-time error occurs unless the token immed iately following $d$ is \code{`.'}. |
5272 \item If $d$ is a class or type alias $T$, the value of $e$ is an instance of c lass \code{Type} (or a subclass thereof) reifying $T$. | 5272 \item If $d$ is a class or type alias $T$, the value of $e$ is an instance of c lass \code{Type} (or a subclass thereof) reifying $T$. |
5273 \item If $d$ is a type parameter $T$, then the value of $e$ is the value of the actual type argument corresponding to $T$ that was passed to the generative con structor that created the current binding of \THIS{}. If, however, $e$ occurs in side a static member, a compile-time error occurs. | 5273 \item If $d$ is a type parameter $T$, then the value of $e$ is the value of the actual type argument corresponding to $T$ that was passed to the generative con structor that created the current binding of \THIS{}. If, however, $e$ occurs in side a static member, a compile-time error occurs. |
5274 | 5274 |
5275 %\commentary{ We are assured that \THIS{} is well defined, because if we were in a static member the reference to $T$ is a compile-time error (\ref{generics}.)} | 5275 %\commentary{ We are assured that \THIS{} is well defined, because if we were in a static member the reference to $T$ is a compile-time error (\ref{generics}.)} |
5276 %\item If $d$ is a library variable then: | 5276 %\item If $d$ is a library variable then: |
5277 % \begin{itemize} | 5277 % \begin{itemize} |
5278 % \item If $d$ is of one of the forms \code{\VAR{} $v$ = $e_i$;} , \code{$T$ $v $ = $e_i$;} , \code{\FINAL{} $v$ = $e_i$;} or \code{\FINAL{} $T$ $v$ = $e_i$;} and no value has yet been stored into $v$ then the initializer expression $e_i$ is evaluated. If, during the evaluation of $e_i$, the getter for $v$ is referenc ed, a \code{CyclicInitializationError} is thrown. If the evaluation succeeded yi elding an object $o$, let $r = o$, otherwise let $r = \NULL{}$. In any case, $r$ is stored into $v$. The value of $e$ is $r$. | 5278 % \item If $d$ is of one of the forms \code{\VAR{} $v$ = $e_i$;} , \code{$T$ $v $ = $e_i$;} , \code{\FINAL{} $v$ = $e_i$;} or \code{\FINAL{} $T$ $v$ = $e_i$;} and no value has yet been stored into $v$ then the initializer expression $e_i$ is evaluated. If, during the evaluation of $e_i$, the getter for $v$ is referenc ed, a \code{CyclicInitializationError} is thrown. If the evaluation succeeded yi elding an object $o$, let $r = o$, otherwise let $r = \NULL{}$. In any case, $r$ is stored into $v$. The value of $e$ is $r$. |
5279 \item If $d$ is a constant variable of one of the forms \code{\CONST{} $v$ = $e$;} or \code{\CONST{} $T$ $v$ = $e$;} then the value $id$ is the value of the compile-time constant $e$. | 5279 \item If $d$ is a constant variable of one of the forms \code{\CONST{} $v$ = $e$;} or \code{\CONST{} $T$ $v$ = $e$;} then the value $id$ is the value of the compile-time constant $e$. |
5280 % Otherwise | 5280 % Otherwise |
5281 % \item $e$ evaluates to the current binding of $id$. | 5281 % \item $e$ evaluates to the current binding of $id$. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5465 | 5465 |
5466 \subsection{Local Variable Declaration} | 5466 \subsection{Local Variable Declaration} |
5467 \LMLabel{localVariableDeclaration} | 5467 \LMLabel{localVariableDeclaration} |
5468 | 5468 |
5469 | 5469 |
5470 \LMHash{} | 5470 \LMHash{} |
5471 A {\em variable declaration statement }declares a new local variable. | 5471 A {\em variable declaration statement }declares a new local variable. |
5472 | 5472 |
5473 \begin{grammar} | 5473 \begin{grammar} |
5474 {\bf localVariableDeclaration:} | 5474 {\bf localVariableDeclaration:} |
5475 initializedVariableDeclaration {\escapegrammar';'} | 5475 initializedVariableDeclaration `{\escapegrammar ;}' |
5476 . | 5476 . |
5477 \end{grammar} | 5477 \end{grammar} |
5478 | 5478 |
5479 \LMHash{} | 5479 \LMHash{} |
5480 Executing a variable declaration statement of one of the forms \VAR{} $v = e;$ , $T$ $v = e; $, \CONST{} $v = e;$, \CONST{} $T$ $v = e;$, \FINAL{} $v = e;$ o r \FINAL{} $T$ $v = e;$ proceeds as follows: | 5480 Executing a variable declaration statement of one of the forms \VAR{} $v = e;$ , $T$ $v = e; $, \CONST{} $v = e;$, \CONST{} $T$ $v = e;$, \FINAL{} $v = e;$ o r \FINAL{} $T$ $v = e;$ proceeds as follows: |
5481 | 5481 |
5482 \LMHash{} | 5482 \LMHash{} |
5483 The expression $e$ is evaluated to an object $o$. Then, the variable $v$ is set to $o$. | 5483 The expression $e$ is evaluated to an object $o$. Then, the variable $v$ is set to $o$. |
5484 | 5484 |
5485 \LMHash{} | 5485 \LMHash{} |
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7001 \begin{grammar} | 7001 \begin{grammar} |
7002 {\bf type:} | 7002 {\bf type:} |
7003 typeName typeArguments? | 7003 typeName typeArguments? |
7004 . | 7004 . |
7005 | 7005 |
7006 {\bf typeName:} | 7006 {\bf typeName:} |
7007 qualified | 7007 qualified |
7008 . | 7008 . |
7009 | 7009 |
7010 {\bf typeArguments:} | 7010 {\bf typeArguments:} |
7011 '<' typeList '>' | 7011 `<' typeList `>' |
7012 . | 7012 . |
7013 | 7013 |
7014 {\bf typeList:} | 7014 {\bf typeList:} |
7015 type (',' type)* | 7015 type (`,' type)* |
7016 . | 7016 . |
7017 \end{grammar} | 7017 \end{grammar} |
7018 | 7018 |
7019 \LMHash{} | 7019 \LMHash{} |
7020 A Dart implementation must provide a static checker that detects and reports exa ctly those situations this specification identifies as static warnings and only those situations. However: | 7020 A Dart implementation must provide a static checker that detects and reports exa ctly those situations this specification identifies as static warnings and only those situations. However: |
7021 \begin{itemize} | 7021 \begin{itemize} |
7022 \item Running the static checker on a program $P$ is not required for compiling and running $P$. | 7022 \item Running the static checker on a program $P$ is not required for compiling and running $P$. |
7023 \item Running the static checker on a program $P$ must not prevent successful co mpilation of $P$ nor may it prevent the execution of $P$, regardless of whether any static warnings occur. | 7023 \item Running the static checker on a program $P$ must not prevent successful co mpilation of $P$ nor may it prevent the execution of $P$, regardless of whether any static warnings occur. |
7024 \end{itemize} | 7024 \end{itemize} |
7025 | 7025 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7110 | 7110 |
7111 \begin{dartCode} | 7111 \begin{dartCode} |
7112 \VAR{} i; | 7112 \VAR{} i; |
7113 i j; // a variable j of type i (supposedly) | 7113 i j; // a variable j of type i (supposedly) |
7114 main() \{ | 7114 main() \{ |
7115 j = 'I am not an i'; | 7115 j = 'I am not an i'; |
7116 \} | 7116 \} |
7117 \end{dartCode} | 7117 \end{dartCode} |
7118 | 7118 |
7119 \commentary{ | 7119 \commentary{ |
7120 Since $i$ is not a type, a static warning will be issue at the declaration of $j $. However, the program can be executed without incident in production mode beca use he undeclared type $i$ is treated as \DYNAMIC{}. However, in checked mode, t he implicit subtype test at the assignment will trigger an error at runtime. | 7120 Since $i$ is not a type, a static warning will be issue at the declaration of $j $. However, the program can be executed without incident in production mode beca use the undeclared type $i$ is treated as \DYNAMIC{}. However, in checked mode, the implicit subtype test at the assignment will trigger an error at runtime. |
7121 } | 7121 } |
7122 | 7122 |
7123 | 7123 |
7124 \commentary{ | 7124 \commentary{ |
7125 Here is an example involving malbounded types: | 7125 Here is an example involving malbounded types: |
7126 } | 7126 } |
7127 | 7127 |
7128 \begin{dartCode} | 7128 \begin{dartCode} |
7129 \CLASS{} I$<$T \EXTENDS{} num$>$ \{\} | 7129 \CLASS{} I$<$T \EXTENDS{} num$>$ \{\} |
7130 \CLASS{} J \{\} | 7130 \CLASS{} J \{\} |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7469 | 7469 |
7470 | 7470 |
7471 | 7471 |
7472 \subsection{Parameterized Types} | 7472 \subsection{Parameterized Types} |
7473 \LMLabel{parameterizedTypes} | 7473 \LMLabel{parameterizedTypes} |
7474 | 7474 |
7475 \LMHash{} | 7475 \LMHash{} |
7476 A {\em parameterized type} is an invocation of a generic type declaration. | 7476 A {\em parameterized type} is an invocation of a generic type declaration. |
7477 | 7477 |
7478 \LMHash{} | 7478 \LMHash{} |
7479 Let $T$ be a parameterized type $G<S_1, \ldots, S_n>$. If $G$ is not a generic type, the type arguments $S_i$, $1 \le i \le n$ are discarded. If $G$ has $m \n e n$ type parameters, $T$ is treated as as a parameterized type with $m$ argumen ts, all of which are \DYNAMIC{}. | 7479 Let $T$ be a parameterized type $G<S_1, \ldots, S_n>$. If $G$ is not a generic type, the type arguments $S_i$, $1 \le i \le n$ are discarded. If $G$ has $m \n e n$ type parameters, $T$ is treated as a parameterized type with $m$ arguments, all of which are \DYNAMIC{}. |
7480 | 7480 |
7481 \commentary{In short, any arity mismatch results in all type arguments being dro pped, and replaced with the correct number of type arguments, all set to \DYNAMI C{}. Of course, a static warning will be issued. | 7481 \commentary{In short, any arity mismatch results in all type arguments being dro pped, and replaced with the correct number of type arguments, all set to \DYNAMI C{}. Of course, a static warning will be issued. |
7482 } | 7482 } |
7483 | 7483 |
7484 \LMHash{} | 7484 \LMHash{} |
7485 Otherwise, let | 7485 Otherwise, let |
7486 $T_i$ be the type parameters of $G$ and let $B_i$ be the bound of $T_i, i \in 1.. n$,. $T$ is {\em malbounded} iff either $S_i$ is malbounded or $S_i$ is not a subtype of $[S_1, \ldots, S_n/T_1, \ldots, T_n]B_i, i \in 1.. n$. | 7486 $T_i$ be the type parameters of $G$ and let $B_i$ be the bound of $T_i, i \in 1.. n$,. $T$ is {\em malbounded} iff either $S_i$ is malbounded or $S_i$ is not a subtype of $[S_1, \ldots, S_n/T_1, \ldots, T_n]B_i, i \in 1.. n$. |
7487 | 7487 |
7488 \commentary{ | 7488 \commentary{ |
7489 Note, that, in checked mode, it is a dynamic type error if a malbounded type is used in a type test as specified in \ref{dynamicTypeSystem}. | 7489 Note, that, in checked mode, it is a dynamic type error if a malbounded type is used in a type test as specified in \ref{dynamicTypeSystem}. |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7864 | 7864 |
7865 The invariant that each normative paragraph is associated with a line | 7865 The invariant that each normative paragraph is associated with a line |
7866 containing the text \LMHash{} should be maintained. Extra occurrences | 7866 containing the text \LMHash{} should be maintained. Extra occurrences |
7867 of \LMHash{} can be added if needed, e.g., in order to make | 7867 of \LMHash{} can be added if needed, e.g., in order to make |
7868 individual \item{}s in itemized lists addressable. Each \LM.. command | 7868 individual \item{}s in itemized lists addressable. Each \LM.. command |
7869 must occur on a separate line. \LMHash{} must occur immediately | 7869 must occur on a separate line. \LMHash{} must occur immediately |
7870 before the associated paragraph, and \LMLabel must occur immediately | 7870 before the associated paragraph, and \LMLabel must occur immediately |
7871 after the associated \section{}, \subsection{} etc. | 7871 after the associated \section{}, \subsection{} etc. |
7872 | 7872 |
7873 ---------------------------------------------------------------------- | 7873 ---------------------------------------------------------------------- |
OLD | NEW |