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 19 matching lines...) Expand all Loading... | |
30 \LMHash{} | 30 \LMHash{} |
31 This Ecma standard specifies the syntax and semantics of the Dart programming la nguage. It does not specify the APIs of the Dart libraries except where those l ibrary elements are essential to the correct functioning of the language itself (e.g., the existence of class \cd{Object} with methods such as \cd{noSuchMethod} , \cd{runtimeType}). | 31 This Ecma standard specifies the syntax and semantics of the Dart programming la nguage. It does not specify the APIs of the Dart libraries except where those l ibrary elements are essential to the correct functioning of the language itself (e.g., the existence of class \cd{Object} with methods such as \cd{noSuchMethod} , \cd{runtimeType}). |
32 | 32 |
33 \section{Conformance} | 33 \section{Conformance} |
34 \LMLabel{ecmaConformance} | 34 \LMLabel{ecmaConformance} |
35 | 35 |
36 \LMHash{} | 36 \LMHash{} |
37 A conforming implementation of the Dart programming language must provide and s upport all the APIs (libraries, types, functions, getters, setters, whether top -level, static, instance or local) mandated in this specification. | 37 A conforming implementation of the Dart programming language must provide and s upport all the APIs (libraries, types, functions, getters, setters, whether top -level, static, instance or local) mandated in this specification. |
38 | 38 |
39 \LMHash{} | 39 \LMHash{} |
40 A conforming implementation is permitted to provide additional APIs, but not add itional syntax. | 40 A conforming implementation is permitted to provide additional APIs, but not add itional syntax, except for experimental features in support of null-aware cascad es and tear-offs that are likely to be introduced in the next revision of this s pecification. |
41 | 41 |
42 \section{Normative References} | 42 \section{Normative References} |
43 \LMLabel{ecmaNormativeReferences} | 43 \LMLabel{ecmaNormativeReferences} |
44 | 44 |
45 \LMHash{} | 45 \LMHash{} |
46 The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated ref erences, the latest edition of the referenced document (including any amendments ) applies. | 46 The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated ref erences, the latest edition of the referenced document (including any amendments ) applies. |
47 | 47 |
48 \begin{enumerate} | 48 \begin{enumerate} |
49 \item | 49 \item |
50 The Unicode Standard, Version 5.0, as amended by Unicode 5.1.0, or successor. | 50 The Unicode Standard, Version 5.0, as amended by Unicode 5.1.0, or successor. |
(...skipping 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2342 . | 2342 . |
2343 \end{grammar} | 2343 \end{grammar} |
2344 | 2344 |
2345 \begin{grammar} | 2345 \begin{grammar} |
2346 {\bf primary:}thisExpression; | 2346 {\bf primary:}thisExpression; |
2347 \SUPER{} assignableSelector; | 2347 \SUPER{} assignableSelector; |
2348 functionExpression; | 2348 functionExpression; |
2349 literal; | 2349 literal; |
2350 identifier; | 2350 identifier; |
2351 newExpression; | 2351 newExpression; |
2352 \NEW{} type `\#' (`{\escapegrammar .}' identifier)?; | |
2352 constObjectExpression; | 2353 constObjectExpression; |
2353 `(' expression `)' | 2354 `(' expression `)' |
2354 . | 2355 . |
2355 | 2356 |
2356 \end{grammar} | 2357 \end{grammar} |
2357 | 2358 |
2358 \LMHash{} | 2359 \LMHash{} |
2359 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$. | 2360 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$. |
2360 | 2361 |
2361 \commentary{ | 2362 \commentary{ |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3518 \item If $s$ has been canceled then its cancellation future is completed with $x$ as an error. | 3519 \item If $s$ has been canceled then its cancellation future is completed with $x$ as an error. |
3519 \end{itemize} | 3520 \end{itemize} |
3520 \item $s$ is closed. | 3521 \item $s$ is closed. |
3521 \end{itemize} | 3522 \end{itemize} |
3522 | 3523 |
3523 \rationale{ | 3524 \rationale{ |
3524 When an asynchronous generator's stream has been canceled, cleanup will occur in the \FINALLY{} clauses (\ref{try}) inside the generator. We choose to direct an y exceptions that occur at this time to the cancellation future rather than have them be lost. | 3525 When an asynchronous generator's stream has been canceled, cleanup will occur in the \FINALLY{} clauses (\ref{try}) inside the generator. We choose to direct an y exceptions that occur at this time to the cancellation future rather than have them be lost. |
3525 } | 3526 } |
3526 | 3527 |
3527 \LMHash{} | 3528 \LMHash{} |
3528 If $f$ is asynchronous then, when $f$ terminates, any open stream subscriptions associated with any asynchronous for loops (\ref{asynchronousFor-in}) or yield- each statements (\ref{yieldEach}) executing within $f$ are canceled. | 3529 If $f$ is asynchronous then, when $f$ terminates, any open stream subscriptions associated with any asynchronous for loops (\ref{asynchronousFor-in}) or yield- each statements (\ref{yieldEach}) executing within $f$ are canceled, in the ord er of their nesting, innermost first. |
3529 | 3530 |
3530 \rationale{Such streams may be left open by for loops that were escaped when an exception was thrown within them for example. | 3531 \rationale{Such streams may be left open by for loops that were escaped when an exception was thrown within them for example. |
3531 } | 3532 } |
3532 | 3533 |
3534 %\LMHash{} | |
3535 %When a stream is canceled, the implementation must wait for the cancelation fut ure returned by \cd{cancell()} to complete before proceeding. | |
Lasse Reichstein Nielsen
2015/03/27 07:03:04
Still commented out (and two l's in "cancell").
| |
3536 | |
3533 \LMHash{} | 3537 \LMHash{} |
3534 If $f$ is marked \SYNC* (\ref{functions}), then a fresh instance $i$ implementin g the built-in class \code{Iterable} is associated with the invocation and immed iately returned. | 3538 If $f$ is marked \SYNC* (\ref{functions}), then a fresh instance $i$ implementin g the built-in class \code{Iterable} is associated with the invocation and immed iately returned. |
3535 | 3539 |
3536 | 3540 |
3537 \commentary{ | 3541 \commentary{ |
3538 A Dart implementation will need to provide a specific implementation of \code{It erable} that will be returned by \SYNC* methods. A typical strategy would be to produce an instance of a subclass of class \code{IterableBase} defined in \code{ dart:core}. The only method that needs to be added by the Dart implementation in that case is \code{iterator}. | 3542 A Dart implementation will need to provide a specific implementation of \code{It erable} that will be returned by \SYNC* methods. A typical strategy would be to produce an instance of a subclass of class \code{IterableBase} defined in \code{ dart:core}. The only method that needs to be added by the Dart implementation in that case is \code{iterator}. |
3539 } | 3543 } |
3540 | 3544 |
3541 \LMHash{} | 3545 \LMHash{} |
3542 The iterable implementation must comply with the contract of \code{Iterable} and should not take any steps identified as exceptionally efficient in that contrac t. | 3546 The iterable implementation must comply with the contract of \code{Iterable} and should not take any steps identified as exceptionally efficient in that contrac t. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3768 \subsection{ Method Invocation} | 3772 \subsection{ Method Invocation} |
3769 \LMLabel{methodInvocation} | 3773 \LMLabel{methodInvocation} |
3770 | 3774 |
3771 \LMHash{} | 3775 \LMHash{} |
3772 Method invocation can take several forms as specified below. | 3776 Method invocation can take several forms as specified below. |
3773 | 3777 |
3774 \subsubsection{Ordinary Invocation} | 3778 \subsubsection{Ordinary Invocation} |
3775 \LMLabel{ordinaryInvocation} | 3779 \LMLabel{ordinaryInvocation} |
3776 | 3780 |
3777 \LMHash{} | 3781 \LMHash{} |
3778 An ordinary method invocation $i$ has the form | 3782 An ordinary method invocation can be {\em conditional} or {\em unconditional}. |
3783 | |
3784 \LMHash{} | |
3785 Evaluation of a {\em conditional ordinary method invocation} $e$ of the form | |
3786 | |
3787 \LMHash{} | |
3788 $o?.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ | |
3789 | |
3790 \LMHash{} | |
3791 is equivalent to the evaluation of the expression | |
3792 | |
3793 \LMHash{} | |
3794 $((x) => x == \NULL ? \NULL : x.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}))(o)$. | |
3795 | |
3796 \LMHash{} | |
3797 The static type of $e$ is the same as the static type of $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. Exactly the same static warnings that would be caused by $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n +k}: a_{n+k})$ are also generated in the case of $o?.m(a_1, \ldots , a_n, x_{n+1 }: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. | |
3798 | |
3799 \LMHash{} | |
3800 An {\em unconditional ordinary method invocation} $i$ has the form | |
3779 | 3801 |
3780 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. | 3802 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. |
3781 | 3803 |
3782 \LMHash{} | 3804 \LMHash{} |
3783 Evaluation of an ordinary method invocation $i$ of the form | 3805 Evaluation of an unconditional ordinary method invocation $i$ of the form |
3784 | 3806 |
3785 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ | 3807 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ |
3786 | 3808 |
3787 proceeds as follows: | 3809 proceeds as follows: |
3788 | 3810 |
3789 \LMHash{} | 3811 \LMHash{} |
3790 First, the expression $o$ is evaluated to a value $v_o$. Next, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k}$. Let $f$ be the result of looking up (\ref{methodLookup}) method $m$ in $v_o$ with respect to the cur rent library $L$. | 3812 First, the expression $o$ is evaluated to a value $v_o$. Next, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k}$. Let $f$ be the result of looking up (\ref{methodLookup}) method $m$ in $v_o$ with respect to the cur rent library $L$. |
3791 | 3813 |
3792 \LMHash{} | 3814 \LMHash{} |
3793 Let $p_1 \ldots p_h$ be the required parameters of $f$, let $p_1 \ldots p_m$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+l}$ be the opti onal parameters declared by $f$. | 3815 Let $p_1 \ldots p_h$ be the required parameters of $f$, let $p_1 \ldots p_m$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+l}$ be the opti onal parameters declared by $f$. |
(...skipping 11 matching lines...) Expand all Loading... | |
3805 \LMHash{} | 3827 \LMHash{} |
3806 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $v_o$ with respect to $L$. | 3828 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $v_o$ with respect to $L$. |
3807 If $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, t hen if $g$ is a getter that forwards to a static getter, getter lookup fails. | 3829 If $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, t hen if $g$ is a getter that forwards to a static getter, getter lookup fails. |
3808 If the getter lookup succeeded, let $v_g$ be the value of the getter invocation $o.m$. Then the value of $i$ is the result of invoking | 3830 If the getter lookup succeeded, let $v_g$ be the value of the getter invocation $o.m$. Then the value of $i$ is the result of invoking |
3809 the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_ n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$. | 3831 the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_ n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$. |
3810 | 3832 |
3811 \LMHash{} | 3833 \LMHash{} |
3812 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : | 3834 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : |
3813 \begin{itemize} | 3835 \begin{itemize} |
3814 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3836 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3815 \item \code{im.memberName} evaluates to \code{'m'}. | 3837 \item \code{im.memberName} evaluates to the symbol \code{m}. |
3816 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. | 3838 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. |
3817 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}. | 3839 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}. |
3818 \end{itemize} | 3840 \end{itemize} |
3819 | 3841 |
3820 \LMHash{} | 3842 \LMHash{} |
3821 Then the method \code{noSuchMethod()} is looked up in $v_o$ and invoked with arg ument $im$, and the result of this invocation is the result of evaluating $i$. H owever, if the implementation found cannot be invoked with a single positional a rgument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $v_o$ with argument $im'$, where $im'$ is an instance of \code{Invoca tion} such that : | 3843 Then the method \code{noSuchMethod()} is looked up in $v_o$ and invoked with arg ument $im$, and the result of this invocation is the result of evaluating $i$. H owever, if the implementation found cannot be invoked with a single positional a rgument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $v_o$ with argument $im'$, where $im'$ is an instance of \code{Invoca tion} such that : |
3822 \begin{itemize} | 3844 \begin{itemize} |
3823 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3845 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. |
3824 \item \code{im.memberName} evaluates to \code{noSuchMethod'}. | 3846 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. |
3825 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 3847 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. |
3826 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 3848 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3827 \end{itemize} | 3849 \end{itemize} |
3828 | 3850 |
3829 and the result of the latter invocation is the result of evaluating $i$. | 3851 and the result of the latter invocation is the result of evaluating $i$. |
3830 | 3852 |
3831 \rationale { | 3853 \rationale { |
3832 It is possible to bring about such a situation by overriding \code{noSuchMethod( )} with the wrong number of arguments:} | 3854 It is possible to bring about such a situation by overriding \code{noSuchMethod( )} with the wrong number of arguments:} |
3833 | 3855 |
3834 \begin{code} | 3856 \begin{code} |
3835 \CLASS{} Perverse \{ | 3857 \CLASS{} Perverse \{ |
3836 noSuchMethod(x,y) =$>$ x + y; | 3858 noSuchMethod(x,y) =$>$ x + y; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3869 . | 3891 . |
3870 | 3892 |
3871 {\bf cascadeSelector:}`[' expression `]'; | 3893 {\bf cascadeSelector:}`[' expression `]'; |
3872 identifier | 3894 identifier |
3873 . | 3895 . |
3874 \end{grammar} | 3896 \end{grammar} |
3875 | 3897 |
3876 \LMHash{} | 3898 \LMHash{} |
3877 A cascaded method invocation expression of the form {\em e..suffix} is equivalen t to the expression \code{(t)\{t.{\em suffix}; \RETURN{} t;\}($e$)}. | 3899 A cascaded method invocation expression of the form {\em e..suffix} is equivalen t to the expression \code{(t)\{t.{\em suffix}; \RETURN{} t;\}($e$)}. |
3878 | 3900 |
3901 \rationale{ | |
3902 With the introduction of null-aware conditional assignable expressions (\ref{ass ignableExpressions}), it would make sense to extend cascades with a null-aware c onditional form as well. One might define {\em e?..suffix} to be equivalent to the expression \code{(t)\{t?.{\em suffix}; \RETURN{} t;\}($e$)}. | |
3903 | |
3904 The present specification has not added such a construct, in the interests of si mplicity and rapid language evolution. However, Dart implementations may experim ent with such constructs, as noted in section \ref{ecmaConformance}. | |
3905 } | |
3906 | |
3879 \subsubsection{Super Invocation} | 3907 \subsubsection{Super Invocation} |
3880 \LMLabel{superInvocation} | 3908 \LMLabel{superInvocation} |
3881 | 3909 |
3882 \LMHash{} | 3910 \LMHash{} |
3883 A super method invocation $i$ has the form | 3911 A super method invocation $i$ has the form |
3884 | 3912 |
3885 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. | 3913 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. |
3886 | 3914 |
3887 \LMHash{} | 3915 \LMHash{} |
3888 Evaluation of $i$ proceeds as follows: | 3916 Evaluation of $i$ proceeds as follows: |
3889 | 3917 |
3890 \LMHash{} | 3918 \LMHash{} |
3891 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k }$. Let $S$ be the superclass of the immediately enclosing class, and let $f$ be the result of looking up method (\ref{ordinaryInvocation}) $m$ in $S$ with re spect to the current library $L$. | 3919 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k }$. Let $S$ be the superclass of the immediately enclosing class, and let $f$ be the result of looking up method (\ref{ordinaryInvocation}) $m$ in $S$ with re spect to the current library $L$. |
3892 Let $p_1 \ldots p_h$ be the required parameters of $f$, let $p_1 \ldots p_m$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+l}$ be the opti onal parameters declared by $f$. | 3920 Let $p_1 \ldots p_h$ be the required parameters of $f$, let $p_1 \ldots p_m$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+l}$ be the opti onal parameters declared by $f$. |
3893 | 3921 |
3894 \LMHash{} | 3922 \LMHash{} |
3895 If $n < h$, or $n > m$, the method lookup has failed. Furthermore, each $x_i, n +1 \le i \le n+k$, must have a corresponding named parameter in the set $\{p_{m +1}, \ldots, p_{h+l}\}$ or the method lookup also fails. Otherwise method looku p has succeeded. | 3923 If $n < h$, or $n > m$, the method lookup has failed. Furthermore, each $x_i, n +1 \le i \le n+k$, must have a corresponding named parameter in the set $\{p_{m +1}, \ldots, p_{h+l}\}$ or the method lookup also fails. Otherwise method looku p has succeeded. |
3896 | 3924 |
3897 \LMHash{} | 3925 \LMHash{} |
3898 If the method lookup succeeded, the body of $f$ is executed with respect to the bindings that resulted from the evaluation of the argument list, and with \THIS{ } bound to the current value of \THIS{}. The value of $i$ is the value returned after $f$ is executed. | 3926 If the method lookup succeeded, the body of $f$ is executed with respect to the bindings that resulted from the evaluation of the argument list, and with \THIS{ } bound to the current value of \THIS{}. The value of $i$ is the value returned after $f$ is executed. |
3899 | 3927 |
3900 \LMHash{} | 3928 \LMHash{} |
3901 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $S$ with respect to $L$. If the getter loo kup succeeded, let $v_g$ be the value of the getter invocation $\SUPER{}.m$. The n the value of $i$ is the result of invoking | 3929 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $S$ with respect to $L$. If the getter loo kup succeeded, let $v_g$ be the value of the getter invocation $\SUPER{}.m$. The n the value of $i$ is the result of invoking |
3902 the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_ n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$. | 3930 the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_ n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$. |
3903 | 3931 |
3904 \LMHash{} | 3932 \LMHash{} |
3905 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : | 3933 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : |
3906 \begin{itemize} | 3934 \begin{itemize} |
3907 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3935 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3908 \item \code{im.memberName} evaluates to \code{'m'}. | 3936 \item \code{im.memberName} evaluates to the symbol \code{m}. |
3909 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. | 3937 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. |
3910 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}. | 3938 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}. |
3911 \end{itemize} | 3939 \end{itemize} |
3912 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked on \THIS{} with argument $im$, and the result of this invocation is the result of evaluati ng $i$. However, if the implementation found cannot be invoked with a single pos itional argument, the implementation of \code{noSuchMethod()} in class \code{Ob ject} is invoked on \THIS{} with argument $im'$, where $im'$ is an instance of \ code{Invocation} such that : | 3940 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked on \THIS{} with argument $im$, and the result of this invocation is the result of evaluati ng $i$. However, if the implementation found cannot be invoked with a single pos itional argument, the implementation of \code{noSuchMethod()} in class \code{Ob ject} is invoked on \THIS{} with argument $im'$, where $im'$ is an instance of \ code{Invocation} such that : |
3913 \begin{itemize} | 3941 \begin{itemize} |
3914 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3942 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. |
3915 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 3943 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. |
3916 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 3944 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. |
3917 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 3945 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3918 \end{itemize} | 3946 \end{itemize} |
3919 | 3947 |
3920 and the result of this latter invocation is the result of evaluating $i$. | 3948 and the result of this latter invocation is the result of evaluating $i$. |
3921 | 3949 |
3922 | 3950 |
3923 \LMHash{} | 3951 \LMHash{} |
3924 It is a compile-time error if a super method invocation occurs in a top-level fu nction or variable initializer, in an instance variable initializer or initializ er list, in class \code{Object}, in a factory constructor or in a static method or variable initializer. | 3952 It is a compile-time error if a super method invocation occurs in a top-level fu nction or variable initializer, in an instance variable initializer or initializ er list, in class \code{Object}, in a factory constructor or in a static method or variable initializer. |
3925 | 3953 |
3926 \LMHash{} | 3954 \LMHash{} |
3927 It is a static type warning if $S$ does not have an accessible (\ref{privacy}) i nstance member named $m$ unless $S$ or a superinterface of $S$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defin ed in \code{dart:core}. If $S.m$ exists, it is a static type warning if the typ e $F$ of $S.m$ may not be assigned to a function type. If $S.m$ does not exist, or if $F$ is not a function type, the static type of $i$ is \DYNAMIC{}; otherwis e the static type of $i$ is the declared return type of $F$. | 3955 It is a static type warning if $S$ does not have an accessible (\ref{privacy}) i nstance member named $m$ unless $S$ or a superinterface of $S$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defin ed in \code{dart:core}. If $S.m$ exists, it is a static type warning if the typ e $F$ of $S.m$ may not be assigned to a function type. If $S.m$ does not exist, or if $F$ is not a function type, the static type of $i$ is \DYNAMIC{}; otherwis e the static type of $i$ is the declared return type of $F$. |
(...skipping 11 matching lines...) Expand all Loading... | |
3939 | 3967 |
3940 \commentary{In other words, the methods supporting sending messages embody primi tives of Dart that are not accessible to ordinary code, much like the methods th at spawn isolates. | 3968 \commentary{In other words, the methods supporting sending messages embody primi tives of Dart that are not accessible to ordinary code, much like the methods th at spawn isolates. |
3941 } | 3969 } |
3942 | 3970 |
3943 | 3971 |
3944 | 3972 |
3945 \subsection{ Property Extraction} | 3973 \subsection{ Property Extraction} |
3946 \LMLabel{propertyExtraction} | 3974 \LMLabel{propertyExtraction} |
3947 | 3975 |
3948 \LMHash{} | 3976 \LMHash{} |
3949 {\em Property extraction} allows for a member of an object to be concisely extra cted from the object. | 3977 {\em Property extraction} allows for a member or constructor to be accessed as a property rather than a function. |
3950 A property extraction can be either: | 3978 A property extraction can be either: |
3951 \begin{enumerate} | 3979 \begin{enumerate} |
3952 \item A {\em closurization} (\ref{closurization}) which allows a method to be tr eated as if it were a getter for a function valued object. Or | 3980 \item A {\em closurization} which converts a method or constructor into a closur e. Or |
3953 \item A {\em getter invocation} which returns the result of invoking of a getter method. | 3981 \item A {\em getter invocation} which returns the result of invoking of a getter method. |
3954 \end{enumerate} | 3982 \end{enumerate} |
3955 | 3983 |
3984 | |
3985 \commentary{Closures derived from members via closurization are colloquially kno wn as tear-offs} | |
3986 | |
3987 Property extraction can be either {\em conditional} or {\em unconditional}. | |
3988 | |
3989 \rationale { | |
3990 Tear-offs using the \cd{ x\#id} syntax cannot be conditional at this time; this is inconsistent, and is likely to be addressed in the near future, perhaps via notation such as \cd{ x?\#id} . As indicated in section \ref{ecmaConformance}, experimentation in this area is allowed. | |
3991 } | |
3992 | |
3993 Evaluation of a {\em conditional property extraction expression} $e$ of the form $e_1?.id$ is equivalent to the evaluation of the expression $((x) => x == \NU LL ? \NULL : x.id)(e_1)$. The static type of $e$ is the same as the static type of $e_1.id$. Let $T$ be the static type of $e_1$ and let $y$ be a fresh variable o type $T$. Exactly the same static warnings that would be caused by $y.id$ are also generated in the case of $e_1?.id$. | |
3994 | |
3995 \commentary{ | |
3996 One might be tempted to conclude that for $e \ne \NULL{}$, $e?.v$ is always equi valent to $e.v$. However this is not the case. If $e$ is a type literal represen ting a type with static member $v$, then $e.v$ refers to that member, but $e?.v$ does not. | |
3997 } | |
3998 | |
3999 \LMHash{} | |
4000 Unconditional property extraction takes several syntactic forms: $e.m$ (\ref{get terAccessAndMethodExtraction}), $\SUPER.m$ (\ref{superGetterAccessAndMethodClosu rization}), $e\#m$ (\ref{generalClosurization}), $\NEW{}$ $T\#m$ (\ref{namedCons tructorExtraction}), $\NEW{}$ $T\#$ (\ref{anonymousConstructorExtraction}) and $ \SUPER\#m$ (\ref{generalSuperPropertyExtraction}), where $e$ is an expression, $ m$ is an identifier optionally followed by an equal sign and $T$ is a type. | |
4001 | |
4002 \subsubsection{Getter Access and Method Extraction} | |
4003 \LMLabel{getterAccessAndMethodExtraction} | |
4004 | |
3956 \LMHash{} | 4005 \LMHash{} |
3957 Evaluation of a property extraction $i$ of the form $e.m$ proceeds as follows: | 4006 Evaluation of a property extraction $i$ of the form $e.m$ proceeds as follows: |
3958 | 4007 |
3959 \LMHash{} | 4008 \LMHash{} |
3960 First, the expression $e$ is evaluated to an object $o$. Let $f$ be the result o f looking up (\ref{methodLookup}) method (\ref{instanceMethods}) $m$ in $o$ wit h respect to the current library $L$. If $o$ is an instance of \code{Type} but $e$ is not a constant type literal, then if $m$ is a method that forwards (\ref{ functionDeclarations}) to a static method, method lookup fails. If method looku p succeeds and $f$ is a concrete method then $i$ evaluates to the closurization of $o.m$. | 4009 First, the expression $e$ is evaluated to an object $o$. Let $f$ be the result o f looking up (\ref{methodLookup}) method (\ref{instanceMethods}) $m$ in $o$ wit h respect to the current library $L$. If $o$ is an instance of \code{Type} but $e$ is not a constant type literal, then if $f$ is a method that forwards (\ref{ functionDeclarations}) to a static method, method lookup fails. If method looku p succeeds then $i$ evaluates to the closurization of method $f$ on object $o$ ( \ref{ordinaryMemberClosurization}). |
4010 | |
4011 \commentary { | |
4012 Note that $f$ is never an abstract method, because method lookup skips abstract methods. Hence, if $m$ refers to an abstract method, we will continue to the nex t step. However, since methods and getters never override each other, getter loo kup will necessarily fail as well, and \cd{noSuchMethod()} will ultimately be in voked. The regrettable implication is that the error will refer to a missing get ter rather than an attempt to closurize an abstract method. | |
4013 } | |
3961 | 4014 |
3962 \LMHash{} | 4015 \LMHash{} |
3963 Otherwise, $i$ is a getter invocation, and the getter function (\ref{getters}) $ m$ is looked up (\ref{getterAndSetterLookup}) in $o$ with respect to $L$. If $o $ is an instance of \code{Type} but $e$ is not a constant type literal, then if $m$ is a getter that forwards to a static getter, getter lookup fails. Otherwi se, the body of $m$ is executed with \THIS{} bound to $o$. The value of $i$ is the result returned by the call to the getter function. | 4016 Otherwise, $i$ is a getter invocation. Let $f$ be the result of looking up |
4017 (\ref{getterAndSetterLookup}) getter (\ref{getters}) $m$ in $o$ with respect to $L$. If $o$ is an instance of \code{Type} but $e$ is not a constant type litera l, then if $f$ is a getter that forwards to a static getter, getter lookup fai ls. Otherwise, the body of $f$ is executed with \THIS{} bound to $o$. The value of $i$ is the result returned by the call to the getter function. | |
3964 | 4018 |
3965 \LMHash{} | 4019 \LMHash{} |
3966 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 4020 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : |
3967 \begin{itemize} | 4021 \begin{itemize} |
3968 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. | 4022 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. |
3969 \item \code{im.memberName} evaluates to \code{'m'}. | 4023 \item \code{im.memberName} evaluates to the symbol \code{m}. |
3970 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . | 4024 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . |
3971 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 4025 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3972 \end{itemize} | 4026 \end{itemize} |
3973 Then the method \code{noSuchMethod()} is looked up in $o$ and invoked with argu ment $im$, and the result of this invocation is the result of evaluating $i$. Ho wever, if the implementation found cannot be invoked with a single positional ar gument, the implementation of \code{noSuchMethod()} in class \code{Object} is i nvoked on $o$ with argument $im'$, where $im'$ is an instance of \code{Invocatio n} such that : | 4027 Then the method \code{noSuchMethod()} is looked up in $o$ and invoked with argu ment $im$, and the result of this invocation is the result of evaluating $i$. Ho wever, if the implementation found cannot be invoked with a single positional ar gument, the implementation of \code{noSuchMethod()} in class \code{Object} is i nvoked on $o$ with argument $im'$, where $im'$ is an instance of \code{Invocatio n} such that : |
3974 \begin{itemize} | 4028 \begin{itemize} |
3975 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 4029 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. |
3976 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 4030 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. |
3977 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 4031 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. |
3978 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 4032 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3979 \end{itemize} | 4033 \end{itemize} |
3980 | 4034 |
3981 and the result of this latter invocation is the result of evaluating $i$. | 4035 and the result of this latter invocation is the result of evaluating $i$. |
3982 | 4036 |
3983 \LMHash{} | 4037 \LMHash{} |
3984 It is a compile-time error if $m$ is a member of class \cd{Object} and $e$ is ei ther a prefix object (\ref{imports}) or a constant type literal. | 4038 It is a compile-time error if $m$ is a member of class \cd{Object} and $e$ is ei ther a prefix object (\ref{imports}) or a constant type literal. |
3985 | 4039 |
3986 \commentary { | 4040 \commentary { |
3987 This precludes \code{int.toString} but not \code{(int).toString} because in the latter case, $e$ is a parenthesized expression. | 4041 This precludes \code{int.toString} but not \code{(int).toString} because in the latter case, $e$ is a parenthesized expression. |
3988 } | 4042 } |
3989 | 4043 |
3990 \LMHash{} | 4044 \LMHash{} |
3991 Let $T$ be the static type of $e$. It is a static type warning if $T$ does not have a method or getter named $m$ unless either: | 4045 Let $T$ be the static type of $e$. It is a static type warning if $T$ does not have a method or getter named $m$ unless either: |
3992 \begin{itemize} | 4046 \begin{itemize} |
3993 \item | 4047 \item |
3994 $T$ or a superinterface of $T$ is annotated with an annotation denoting a consta nt identical to the constant \code{@proxy} defined in \code{dart:core}. Or | 4048 $T$ or a superinterface of $T$ is annotated with an annotation denoting a consta nt identical to the constant \code{@proxy} defined in \code{dart:core}. Or |
3995 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static method or getter named $m$. | 4049 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static method or getter named $m$. |
3996 \end{itemize} | 4050 \end{itemize} |
3997 | 4051 |
3998 \LMHash{} | 4052 \LMHash{} |
3999 If $i$ is a getter invocation, the static type of $i$ is: | 4053 The static type of $i$ is: |
4000 \begin{itemize} | 4054 \begin{itemize} |
4001 \item The declared return type of $T.m$, if $T.m$ exists. | 4055 \item The declared return type of $T.m$, if $T$ has an accessible instance gett er named $m$. |
4002 \item The declared return type of $m$, if $T$ is \code{Type}, $e$ is a constant type literal and the class corresponding to $e$ has a static method or getter n amed $m$. | 4056 \item The declared return type of $m$, if $T$ is \code{Type}, $e$ is a constant type literal and the class corresponding to $e$ declares an accessible static g etter named $m$. |
4057 \item The static type of function $T.m$ if $T$ has an accessible instance method named $m$. | |
4058 \item The static type of function $m$, if $T$ is \code{Type}, $e$ is a constant type literal and the class corresponding to $e$ declares an accessible static m ethod named $m$. | |
4003 \item The type \DYNAMIC{} otherwise. | 4059 \item The type \DYNAMIC{} otherwise. |
4004 \end{itemize} | 4060 \end{itemize} |
4005 | 4061 |
4006 \LMHash{} | 4062 |
4007 If $i$ is a closurization, its static type is as described in section \ref{closu rization}. | 4063 \subsubsection{Super Getter Access and Method Closurization} |
4064 \LMLabel{superGetterAccessAndMethodClosurization} | |
4008 | 4065 |
4009 \LMHash{} | 4066 \LMHash{} |
4010 Evaluation of a property extraction $i$ of the form $\SUPER.m$ proceeds as follo ws: | 4067 Evaluation of a property extraction $i$ of the form $\SUPER.m$ proceeds as follo ws: |
4011 | 4068 |
4012 \LMHash{} | 4069 \LMHash{} |
4013 Let $S$ be the superclass of the immediately enclosing class. Let $f$ be the re sult of looking up method $m$ in $S$ with respect to the current library $L$. I f $f$ is a concrete method then $i$ evaluates to the closurization of $\SUPER.m$ with respect to superclass $S$(\ref{closurization}). | 4070 Let $S$ be the superclass of the immediately enclosing class. Let $f$ be the re sult of looking up method $m$ in $S$ with respect to the current library $L$. I f method lookup succeeds then $i$ evaluates to the closurization of method $f$ w ith respect to superclass $S$ (\ref{superClosurization}). |
4014 | 4071 |
4015 \LMHash{} | 4072 \LMHash{} |
4016 Otherwise, $i$ is a getter invocation and the getter function $m$ is looked up in $S$ with respect to $L$, and its body is executed with \THIS{} bound to the current value of \THIS{}. The value of $i$ is the result returned by the call to the getter function. | 4073 Otherwise, $i$ is a getter invocation. Let $f$ be the result of looking up ge tter $m$ in $S$ with respect to $L$. The body of $f$ is executed with \THIS{} bound to the current value of \THIS{}. The value of $i$ is the result returne d by the call to the getter function. |
4017 | 4074 |
4018 \LMHash{} | 4075 \LMHash{} |
4019 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 4076 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : |
4020 \begin{itemize} | 4077 \begin{itemize} |
4021 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. | 4078 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. |
4022 \item \code{im.memberName} evaluates to \code{'m'}. | 4079 \item \code{im.memberName} evaluates to the symbol \code{m}. |
4023 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . | 4080 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . |
4024 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 4081 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
4025 \end{itemize} | 4082 \end{itemize} |
4026 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked with argu ment $im$, and the result of this invocation is the result of evaluating $i$. Ho wever, if the implementation found cannot be invoked with a single positional ar gument, the implementation of \code{noSuchMethod()} in class \code{Object} is i nvoked on \THIS{} with argument $im'$, where $im'$ is an instance of \code{Invoc ation} such that : | 4083 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked with argu ment $im$, and the result of this invocation is the result of evaluating $i$. Ho wever, if the implementation found cannot be invoked with a single positional ar gument, the implementation of \code{noSuchMethod()} in class \code{Object} is i nvoked on \THIS{} with argument $im'$, where $im'$ is an instance of \code{Invoc ation} such that : |
4027 \begin{itemize} | 4084 \begin{itemize} |
4028 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 4085 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. |
4029 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 4086 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. |
4030 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 4087 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. |
4031 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 4088 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
4032 \end{itemize} | 4089 \end{itemize} |
4033 | |
4034 and the result of this latter invocation is the result of evaluating $i$. | 4090 and the result of this latter invocation is the result of evaluating $i$. |
4035 | 4091 |
4036 \LMHash{} | 4092 \LMHash{} |
4037 It is a static type warning if $S$ does not have a method or getter named $m$. If $i$ is a getter invocation, the static type of $i$ is the declared return typ e of $S.m$, if $S.m$ exists and \DYNAMIC{} otherwise. If $i$ is a closurization , its static type is as described in section \ref{closurization}. | 4093 It is a static type warning if $S$ does not have an accessible instance method o r getter named $m$. |
4094 | |
4095 The static type of $i$ is: | |
4096 \begin{itemize} | |
4097 \item The declared return type of $S.m$, if $S$ has an accessible instance gette r named $m$. | |
4098 \item The static type of function $S.m$ if $S$ has an accessible instance method named $m$. | |
4099 \item The type \DYNAMIC{} otherwise. | |
4100 \end{itemize} | |
4038 | 4101 |
4039 | 4102 |
4040 \subsubsection{Closurization} | 4103 \subsubsection{General Closurization} |
4041 \LMLabel{closurization} | 4104 \LMLabel{generalClosurization} |
4042 | 4105 |
4043 \LMHash{} | 4106 \LMHash{} |
4044 The {\em closurization of $o.m$} is defined to be equivalent to: | 4107 Evaluation of a property extraction $i$ of the form $e\#m$ proceeds as follows: |
4045 | 4108 |
4109 \LMHash{} | |
4110 First, the expression $e$ is evaluated to an object $o$. Then: | |
4111 | |
4112 \LMHash{} | |
4113 if $m$ is a setter name, let $f$ be the result of looking up setter $m$ in $o$ with respect to the current library $L$. If $o$ is an instance of \cd{Type} bu t $e$ is not a constant type literal, then if $f$ is a method that forwards to a static setter, setter lookup fails. If setter lookup succeeds then $i$ evaluate s to the closurization of setter $f$ on object $o$ (\ref{ordinaryMemberClosuriza tion}). | |
4114 If setter lookup failed, a \cd{NoSuchMethodError} is thrown. | |
4115 | |
4116 \rationale { | |
4117 It would be more in keeping with the rules of Dart to invoke \cd{noSuchMethod} i n this and similar cases below. However, current implementations of \cd{noSuchM ethod} cannot distinguish between an invocation of a closurization and an actual call. It is likely that future versions of Dart will provide a mechanism to de tect whether \cd{noSuchMethod} is invoked in response to a closurization, say by means of a getter like \cd{isTearOff}. By being conservative at this stage and insisting on failure, we can ensure that no functioning code will break when/if this functionality is introduced. | |
4118 } | |
4119 | |
4120 | |
4121 \LMHash{} | |
4122 If $m$ is not a setter name, let $f$ be the result of looking up method $m$ in $ o$ with respect to the current library $L$. If $o$ is an instance of \cd{Type} but $e$ is not a constant type literal, then if $f$ is a method that forwards t o a static method, method lookup fails. If method lookup succeeds then $i$ evalu ates to the closurization of method $f$ on object $o$ (\ref{ordinaryMemberClosur ization}). | |
4123 | |
4124 \LMHash{} | |
4125 If method lookup failed, let $f$ be the result of looking up getter $m$ in $o$ w ith respect to the current library $L$. If $o$ is an instance of \cd{Type} but $e$ is not a constant type literal, then if $f$ is a method that forwards to a static getter, getter lookup fails. If getter lookup succeeds then $i$ evaluates to the closurization of getter $f$ on object $o$ (\ref{ordinaryMemberClosurizat ion}). | |
4126 If getter lookup failed, a \cd{NoSuchMethodError} is thrown. | |
4127 | |
4128 | |
4129 | |
4130 | |
4131 %\LMHash{} | |
4132 %Otherwise, a new instance $im$ of the predefined class \code{Invocation} is created, such that : | |
4133 %\begin{itemize} | |
4134 %\item If $m$ is a setter name, \code{im.isSetter} evaluates to \code{\TRUE{}}; otherwise \code{im.isMethod} evaluates to \code{\TRUE{}} | |
4135 %\item \code{im.memberName} evaluates to the symbol \code{m}. | |
4136 %\item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} [] }. | |
4137 %\item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
4138 %\end{itemize} | |
4139 %Then the method \code{noSuchMethod()} is looked up in $o$ and invoked with arg ument $im$, and the result of this invocation is the result of evaluating $i$. H owever, if the implementation found cannot be invoked with a single positional a rgument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $o$ with argument $im'$, where $im'$ is an instance of \code{Invocati on} such that : | |
4140 %\begin{itemize} | |
4141 %\item \code{im'.isMethod} evaluates to \code{\TRUE{}}. | |
4142 %\item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. | |
4143 %\item \code{im'.positionalArguments} evaluates to an immutable list whose sole element is $im$. | |
4144 %\item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
4145 %\end{itemize} | |
4146 %and the result of this latter invocation is the result of evaluating $i$. | |
4147 | |
4148 \LMHash{} | |
4149 It is a compile-time error if $e$ is a prefix object (\ref{imports}) and $m$ ref ers to a type or a member of class \cd{Object}. | |
4150 | |
4151 \commentary{ | |
4152 This restriction is in line with other limitations on the use of prefixes as obj ects. The only permitted uses of $p\#m$ are closurizing top level methods and ge tters imported via the prefix $p$. Top level methods are directly available by t heir qualified names: $p.m$. However, getters and setters are not, and allowing their closurization is the whole point of the $e\#m$ syntax. | |
4153 } | |
4154 | |
4155 \LMHash{} | |
4156 Let $T$ be the static type of $e$. It is a static type warning if $T$ does not h ave an accessible instance method or getter named $m$ unless either: | |
4046 \begin{itemize} | 4157 \begin{itemize} |
4158 \item $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant proxy defined in \cd{dart:core}. Or | |
4159 \item $T$ is \cd{Type}, $e$ is a constant type literal and the class correspondi ng to $e$ declares an accessible static method or getter named $m$. | |
4160 \end{itemize} | |
4047 | 4161 |
4162 The static type of $i$ is: | |
4163 \begin{itemize} | |
4164 \item The static type of function $T.m$, if $T$ has an accessible instance membe r named $m$. | |
4165 \item The static type of function $T.m$, if $T$ is \cd{Type}, $e$ is a constant type literal and the class corresponding to $e$ declares an accessible static me mber or constructor named $m$. | |
4166 \item The type \DYNAMIC{} otherwise. | |
4167 \end{itemize} | |
4168 | |
4169 \subsubsection{Named Constructor Extraction} | |
4170 \LMLabel{namedConstructorExtraction} | |
4171 | |
4172 \LMHash{} | |
4173 Evaluation of a property extraction $i$ of the form \NEW{} $T\#m$ proceeds as fo llows: | |
4174 | |
4175 \LMHash{} | |
4176 If $T$ is a malformed type (\ref{staticTypes}), a dynamic error occurs. If $T$ i s a deferred type with prefix $p$, then if $p$ has not been successfully loaded, a dynamic error occurs. If $T$ does not denote a class, a dynamic error occurs. In checked mode, if $T$ or any of its superclasses is malbounded a dynamic erro r occurs. Otherwise, if the type $T$ does not declare an accessible named constr uctor $f$ with name $m$, a \cd{NoSuchMethodError} is thrown. Otherwise, $i$ eval uates to the closurization of constructor $f$ of type $T$ (\ref{namedConstructor Closurization}). | |
4177 | |
4178 \commentary{Note that if $T$ is malformed or malbounded, a static warning occurs , as always.} | |
4179 | |
4180 \LMHash{} | |
4181 The static type of $i$ is the type of the constructor function, if $T$ denotes a class in the surrounding scope with an accessible constructor $f$ named $m$. Ot herwise the static type of $i$ is \DYNAMIC{}. | |
4182 | |
4183 \subsubsection{Anonymous Constructor Extraction} | |
4184 \LMLabel{anonymousConstructorExtraction} | |
4185 | |
4186 \LMHash{} | |
4187 Evaluation of a property extraction $i$ of the form \NEW{} $T\#$ proceeds as fol lows: | |
4188 | |
4189 \LMHash{} | |
4190 If $T$ is a malformed type (\ref{staticTypes}), a dynamic error occurs. If $T$ i s a deferred type with prefix $p$, then if $p$ has not been successfully loaded, a dynamic error occurs. If $T$ does not denote a class, a dynamic error occurs. In checked mode, if $T$ or any of its superclasses is malbounded a dynamic erro r occurs. Otherwise, if the type $T$ does not declare an accessible anonymous co nstructor, a \cd{NoSuchMethodError} is thrown. Otherwise, $i$ evaluates to the c losurization of the anonymous constructor of type $T$ (\ref{anonymousConstructor Closurization}). | |
4191 | |
4192 \commentary{Again, note that if $T$ is malformed or malbounded, existing rules e nsure that a static warning occurs. This also means that $x\#$ where $x$ is not a type will always give a static warning.} | |
4193 | |
4194 \LMHash{} | |
4195 The static type of $i$ is the type of the constructor function $T()$, if $T$ den otes a class in the surrounding scope with an anonymous constructor $T()$. Other wise the static type of $i$ is \DYNAMIC{}. | |
4196 | |
4197 \subsubsection{General Super Property Extraction} | |
4198 \LMLabel{generalSuperPropertyExtraction} | |
4199 | |
4200 | |
4201 \LMHash{} | |
4202 Evaluation of a property extraction $i$ of the form \SUPER$\#m$ proceeds as foll ows: | |
4203 | |
4204 \LMHash{} | |
4205 Let $S$ be the superclass of the immediately enclosing class. | |
4206 | |
4207 \LMHash{} | |
4208 If $m$ is a setter name, let $f$ be the result of looking up setter $m$ in $S$ w ith respect to the current library $L$. If setter lookup succeeds then $i$ evalu ates to the closurization of setter $f$ with respect to superclass $S$ (\ref{s uperClosurization}). If setter lookup failed, a \cd{NoSuchMethodError} is throw n. | |
4209 | |
4210 If $m$ is not a setter name, let $f$ be the result of looking up method $m$ in $ S$ with respect to the current library $L$. If method lookup succeeds then $i$ e valuates to the closurization of method $m$ with respect to superclass $S$ (\ref {superClosurization}). | |
4211 | |
4212 \LMHash{} | |
4213 Otherwise, let $f$ be the result of looking up getter $m$ in $S$ with respect t o the current library $L$. If getter lookup succeeds then $i$ evaluates to the closurization of getter $f$ with respect to superclass $S$ (\ref{superClosurizat ion}). If getter lookup failed, a \cd{NoSuchMethodError} is thrown. | |
4214 | |
4215 \LMHash{} | |
4216 It is a static type warning if $S$ does not have an accessible instance member n amed $m$. | |
4217 | |
4218 \LMHash{} | |
4219 The static type of $i$ is the static type of the function $S.m$, if $S$ has an accessible instance member named $m$. Otherwise the static type of $i$ is \DYNAM IC{}. | |
4220 | |
4221 | |
4222 | |
4223 \subsubsection{Ordinary Member Closurization} | |
4224 \LMLabel{ordinaryMemberClosurization} | |
4225 | |
4226 | |
4227 \LMHash{} | |
4228 Let $o$ be an object, and let $u$ be a fresh final variable bound to $o$. | |
4229 The {\em closurization of method $f$ on object $o$} is defined to be equivalent to: | |
4230 \begin{itemize} | |
4231 \item $(a) \{\RETURN{}$ $u$ $op$ $a;$\} if $f$ is named $op$ and $op$ is one of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<<$, $> >$} (this precludes closurization of unary -). | |
4232 \item $() \{\RETURN{}$ \~{} $u;$\} if $f$ is named \~{}. | |
4233 \item $(a) \{\RETURN{}$ $u[a];$\} if $f$ is named $[]$. | |
4234 \item $(a, b) \{\RETURN{}$ $u[a] = b;$\} if $f$ is named $[]=$. | |
4048 \item | 4235 \item |
4049 \begin{dartCode} | 4236 \begin{dartCode} |
4050 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ | 4237 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ |
4051 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | 4238 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ |
4052 \} | 4239 \} |
4053 \end{dartCode} | 4240 \end{dartCode} |
4054 | 4241 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and named pa rameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. |
4055 if $m$ has required parameters $r_1, \ldots, r_n$, and named parameters $p_1, \l dots, p_k$ with defaults $d_1, \ldots, d_k$. | |
4056 \item | 4242 \item |
4057 \begin{dartCode} | 4243 \begin{dartCode} |
4058 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | 4244 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ |
4059 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | 4245 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; |
4060 \} | 4246 \} |
4061 \end{dartCode} | 4247 \end{dartCode} |
4062 | 4248 |
4063 if $m$ has required parameters $r_1, \ldots, r_n$, and optional positional param eters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. | 4249 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. |
4064 \end{itemize} | 4250 \end{itemize} |
4065 | 4251 |
4066 where $u$ is a fresh final variable bound to $o$, except that: | 4252 \LMHash{} |
4067 \begin{enumerate} | 4253 Except that iff \code{identical($o_1, o_2$)} then \cd{$o_1\#m$ == $o_2\#m$}, \cd{$o_1.m$ == $o_2.m$}, \cd{$o_1\#m$ == $o_2.m$} and \cd{$o_1.m$ == $o_2\#m$} . |
4068 \item Iff \code{identical($o_1, o_2$)} then \cd{$o_1.m$ == $o_2.m$}. | 4254 %\item The static type of the property extraction is the static type of function $T.m$, where $T$ is the static type of $e$, if $T.m$ is defined. Otherwise the static type of $e.m$ is \DYNAMIC{}. |
4069 \item The static type of the property extraction is the static type of function $T.m$, where $T$ is the static type of $e$, if $T.m$ is defined. Otherwise the s tatic type of $e.m$ is \DYNAMIC{}. | 4255 |
4070 \end{enumerate} | 4256 \LMHash{} |
4257 The {\em closurization of getter $f$ on object $o$} is defined to be equivalent to \cd{()\{\RETURN{} u.m;\}} if $f$ is named $m$, except that iff \code{identic al($o_1, o_2$)} then \cd{$o_1\#m$ == $o_2\#m$}. | |
4258 | |
4259 \LMHash{} | |
4260 The {\em closurization of setter $f$ on object $o$} is defined to be equivalent to \cd{(a)\{\RETURN{} u.m = a;\}} if $f$ is named $m=$, except that iff \code{i dentical($o_1, o_2$)} then \cd{$o_1\#m=$ == $o_2\#m=$}. | |
4071 | 4261 |
4072 \commentary{ | 4262 \commentary{ |
4073 There is no guarantee that \cd{identical($o_1.m, o_2.m$)}. Dart implementations are not required to canonicalize these or any other closures. | 4263 There is no guarantee that \cd{identical($o_1.m, o_2.m$)}. Dart implementations are not required to canonicalize these or any other closures. |
4074 } | 4264 } |
4075 % local functions that have a closure extracted are always different | 4265 % local functions that have a closure extracted are always different |
4076 | 4266 |
4077 \rationale{ | 4267 \rationale{ |
4078 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. | 4268 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. |
4079 } | 4269 } |
4080 | 4270 |
4271 \commentary { | |
4272 Observations: | |
4273 | |
4274 One cannot closurize a constructor, getter or a setter via the dot based syntax. One must use the \# based form. One can tell whether one implemented a property via a method or via a field/getter, which means that one has to plan ahead as t o what construct to use, and that choice is reflected in the interface of the cl ass. | |
4275 } | |
4276 | |
4081 | 4277 |
4082 | 4278 |
4279 \subsubsection{Named Constructor Closurization} | |
4280 \LMLabel{namedConstructorClosurization} | |
4083 | 4281 |
4084 \commentary{Observations: | |
4085 \begin{enumerate} | |
4086 \item One cannot closurize a getter or a setter. | |
4087 \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. | |
4088 \end{enumerate} | |
4089 } | |
4090 | |
4091 | |
4092 | |
4093 \LMHash{} | 4282 \LMHash{} |
4094 The closurization of $\SUPER{}.m$ with respect to superclass $S$ is defined to b e equivalent to: | 4283 The {\em closurization of constructor $f$ of type $T$} is defined to be equivale nt to: |
4095 | |
4096 \begin{itemize} | 4284 \begin{itemize} |
4097 %\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$. | |
4098 %\item $(r_1, \ldots, r_n, rest)\{return$ $o.m(r_1, \ldots, r_n, rest);\}$ if $ m$ has required parameters $r_1, \ldots r_n$, and a rest parameter $rest$. | |
4099 %\item | |
4100 \item | 4285 \item |
4101 \begin{dartCode} | 4286 \begin{dartCode} |
4102 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$\{ | 4287 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ |
4103 \RETURN{} \SUPER{}$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k)$; | 4288 \RETURN{} \NEW{} $T.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ |
4289 \} | |
4290 \end{dartCode} | |
4291 | |
4292 if $f$ is a named constructor with name $m$ that has required parameters $r_1, \ ldots, r_n$, and named parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. | |
4293 \item | |
4294 \begin{dartCode} | |
4295 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | |
4296 \RETURN{} \NEW{} $T.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | |
4104 \} | 4297 \} |
4105 \end{dartCode} | 4298 \end{dartCode} |
4106 | 4299 |
4107 if $m$ has required parameters $r_1, \ldots, r_n$, and named parameters $p_1, \l dots, p_k$ with defaults $d_1, \ldots, d_k$. | 4300 if $f$ is a named constructor with name $m$ that has required parameters $r_1, \ ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. |
4301 \end{itemize} | |
4302 | |
4303 \LMHash{} | |
4304 Except that iff \code{identical($T_1, T_2$)} then \cd{\NEW{} $T_1\#m$ == \NEW {} $T_2\#m$}. | |
4305 | |
4306 \commentary{ | |
4307 The above implies that for non-parameterized types, one can rely on the equality of closures resulting from closurization on the ``same'' type. For parameterize d types, one cannot, since there is no requirement to canonicalize them. | |
4308 } | |
4309 | |
4310 \subsubsection{Anonymous Constructor Closurization} | |
4311 \LMLabel{anonymousConstructorClosurization} | |
4312 | |
4313 \LMHash{} | |
4314 The {\em closurization of anonymous constructor $f$ of type $T$} is defined to b e equivalent to: | |
4315 \begin{itemize} | |
4316 \item | |
4317 \begin{dartCode} | |
4318 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ | |
4319 \RETURN{} \NEW{} $T(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | |
4320 \} | |
4321 \end{dartCode} | |
4322 | |
4323 if $f$ is an anonymous constructor that has required parameters $r_1, \ldots, r_ n$, and named parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. | |
4108 \item | 4324 \item |
4109 \begin{dartCode} | 4325 \begin{dartCode} |
4110 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | 4326 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ |
4111 \RETURN{} \SUPER{}$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | 4327 \RETURN{} \NEW{} $T(r_1, \ldots, r_n, p_1, \ldots, p_k)$; |
4112 \} | 4328 \} |
4113 \end{dartCode} | 4329 \end{dartCode} |
4114 | 4330 |
4115 if $m$ has required parameters $r_1, \ldots, r_n$, and optional positional param eters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. | 4331 if $f$ is an anonymous constructor that has required parameters $r_1, \ldots, r_ n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \l dots, d_k$. |
4116 \end{itemize} | 4332 \end{itemize} |
4117 | 4333 |
4118 \LMHash{} | 4334 \LMHash{} |
4119 Except that: | 4335 Except that iff \code{identical($T_1, T_2$)} then \cd{\NEW{} $T_1\#$ == \NEW{ } $T_2\#$}. |
4120 \begin{enumerate} | 4336 |
4121 \item iff \code{identical($o_1, o_2$)} then \cd{$o_1.m$ == $o_2.m$}. | 4337 |
4338 \subsubsection{Super Closurization} | |
4339 \LMLabel{superClosurization} | |
4340 | |
4341 \LMHash{} | |
4342 The {\em closurization of method $f$ with respect to superclass $S$} is defined to be equivalent to: | |
4343 | |
4344 \LMHash{} | |
4345 \begin{itemize} | |
4346 \item $(a) \{\RETURN{}$ \SUPER{} $op$ $a;$\} if $f$ is named $op$ and $op$ is on e of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<< $, $>>$}. | |
4347 \item $() \{\RETURN{}$ \~{}\SUPER;\} if $f$ is named \~{}. | |
4348 \item $(a) \{\RETURN{}$ $\SUPER[a];$\} if $f$ is named $[]$. | |
4349 \item $(a, b) \{\RETURN{}$ $\SUPER[a] = b;$\} if $f$ is named $[]=$. | |
4350 \item | |
4351 \begin{dartCode} | |
4352 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ | |
4353 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | |
4354 \} | |
4355 \end{dartCode} | |
4356 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and named pa rameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. | |
4122 \item | 4357 \item |
4123 The static type of the property extraction is the static type of the method $S.m $, if $S.m$ is defined. Otherwise the static type of $\SUPER{}.m$ is \DYNAMIC{} . | 4358 \begin{dartCode} |
4124 \end{enumerate} | 4359 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ |
4360 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | |
4361 \} | |
4362 \end{dartCode} | |
4363 | |
4364 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. | |
4365 \end{itemize} | |
4366 | |
4367 \LMHash{} | |
4368 Except that iff two closurizations were created by code declared in the same cla ss with identical bindings of \THIS{} then \cd{\SUPER$_1\#m$ == \SUPER$_2\#m$}, \cd{\SUPER$_1.m$ == \SUPER$_2.m$}, \cd{\SUPER$_1\#m$ == \SUPER$_2.m$} and \cd {\SUPER$_1.m$ == \SUPER$_2\#m$}. | |
4369 | |
4370 | |
4371 \LMHash{} | |
4372 The {\em closurization of getter $f$ with respect to superclass $S$} is defined to be equivalent to \cd{()\{\RETURN{} \SUPER.m;\}} if $f$ is named $m$, except that iff two closurizations were created by code declared in the same class with identical bindings of \THIS{} then \cd{\SUPER$_1\#m$ == \SUPER$_2\#m$}. | |
4373 | |
4374 \LMHash{} | |
4375 The {\em closurization of setter $f$ with respect to superclass $S$} is defined to be equivalent to \cd{(a)\{\RETURN{} \SUPER.m = a;\}} if $f$ is named $m=$, e xcept that iff two closurizations were created by code declared in the same clas s with identical bindings of \THIS{} then \cd{\SUPER$_1\#m=$ == \SUPER$_2\#m=$}. | |
4376 | |
4125 | 4377 |
4126 | 4378 |
4127 \subsection{ Assignment} | 4379 \subsection{ Assignment} |
4128 \LMLabel{assignment} | 4380 \LMLabel{assignment} |
4129 | 4381 |
4130 \LMHash{} | 4382 \LMHash{} |
4131 An assignment changes the value associated with a mutable variable or property. | 4383 An assignment changes the value associated with a mutable variable or property. |
4132 | 4384 |
4133 \begin{grammar} | 4385 \begin{grammar} |
4134 {\bf assignmentOperator:}`=' ; | 4386 {\bf assignmentOperator:}`=' ; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4167 \LMHash{} | 4419 \LMHash{} |
4168 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. | 4420 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. |
4169 | 4421 |
4170 \LMHash{} | 4422 \LMHash{} |
4171 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$. | 4423 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$. |
4172 | 4424 |
4173 \LMHash{} | 4425 \LMHash{} |
4174 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$. | 4426 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$. |
4175 | 4427 |
4176 \LMHash{} | 4428 \LMHash{} |
4429 Evaluation of an assignment $a$ of the form $e_1?.v$ \code{=} $e_2$ is equivalen t to the evaluation of the expression $((x) => x == \NULL? \NULL: x.v = e_2)(e_1 )$. The static type of $a$ is the static type of $e_2$. Let $T$ be the static ty pe of $e_1$ and let $y$ be a fresh variable of type $T$. Exactly the same static warnings that would be caused by $y.v = e_2$ are also generated in the case of $e_1?.v$ \code{=} $e_2$. | |
4430 | |
4431 \LMHash{} | |
4177 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws: | 4432 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws: |
4178 | 4433 |
4179 \LMHash{} | 4434 \LMHash{} |
4180 The expression $e_1$ is evaluated to an object $o_1$. Then, the expression $e_2$ is evaluated to an object $o_2$. Then, the setter $v=$ is looked up (\ref{gett erAndSetterLookup}) in $o_1$ with respect to the current library. If $o_1$ is a n instance of \code{Type} but $e_1$ is not a constant type literal, then if $v=$ is a setter that forwards (\ref{functionDeclarations}) to a static setter, sett er lookup fails. Otherwise, the body of $v=$ is executed with its formal parame ter bound to $o_2$ and \THIS{} bound to $o_1$. | 4435 The expression $e_1$ is evaluated to an object $o_1$. Then, the expression $e_2$ is evaluated to an object $o_2$. Then, the setter $v=$ is looked up (\ref{gett erAndSetterLookup}) in $o_1$ with respect to the current library. If $o_1$ is a n instance of \code{Type} but $e_1$ is not a constant type literal, then if $v=$ is a setter that forwards (\ref{functionDeclarations}) to a static setter, sett er lookup fails. Otherwise, the body of $v=$ is executed with its formal parame ter bound to $o_2$ and \THIS{} bound to $o_1$. |
4181 | 4436 |
4182 \LMHash{} | 4437 \LMHash{} |
4183 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 4438 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : |
4184 \begin{itemize} | 4439 \begin{itemize} |
4185 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. | 4440 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. |
4186 \item \code{im.memberName} evaluates to \code{'v='}. | 4441 \item \code{im.memberName} evaluates to the symbol \code{v=}. |
4187 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_2$]}. | 4442 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_2$]}. |
4188 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 4443 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
4189 \end{itemize} | 4444 \end{itemize} |
4190 | 4445 |
4191 \LMHash{} | 4446 \LMHash{} |
4192 Then the method \code{noSuchMethod()} is looked up in $o_1$ and invoked with ar gument $im$. | 4447 Then the method \code{noSuchMethod()} is looked up in $o_1$ and invoked with ar gument $im$. |
4193 However, if the implementation found cannot be invoked with a single positional argument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $o_1$ with argument $im'$, where $im'$ is an instance of \code{Invoc ation} such that : | 4448 However, if the implementation found cannot be invoked with a single positional argument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $o_1$ with argument $im'$, where $im'$ is an instance of \code{Invoc ation} such that : |
4194 \begin{itemize} | 4449 \begin{itemize} |
4195 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 4450 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. |
4196 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 4451 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. |
4197 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 4452 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. |
4198 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 4453 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
4199 \end{itemize} | 4454 \end{itemize} |
4200 | 4455 |
4201 \LMHash{} | 4456 \LMHash{} |
4202 The value of the assignment expression is $o_2$ irrespective of whether setter l ookup has failed or succeeded. | 4457 The value of the assignment expression is $o_2$ irrespective of whether setter l ookup has failed or succeeded. |
4203 | 4458 |
4204 \LMHash{} | 4459 \LMHash{} |
4205 In checked mode, it is a dynamic type error if $o_2$ is not \NULL{} and the inte rface of the class of $o_2$ is not a subtype of the actual type of $e_1.v$. | 4460 In checked mode, it is a dynamic type error if $o_2$ is not \NULL{} and the inte rface of the class of $o_2$ is not a subtype of the actual type of $e_1.v$. |
4206 | 4461 |
4207 \LMHash{} | 4462 \LMHash{} |
4208 Let $T$ be the static type of $e_1$. It is a static type warning if $T$ does not have an accessible instance setter named $v=$ unless either: | 4463 Let $T$ be the static type of $e_1$. It is a static type warning if $T$ does not have an accessible instance setter named $v=$ unless either: |
4209 \begin{itemize} | 4464 \begin{itemize} |
4210 \item $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \code{dart:core}. Or | 4465 \item $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \code{dart:core}. Or |
4211 \item $T$ is \code{Type}, $e_1$ is a constant type literal and the class corresp onding to $e_1$ has a static setter named $v=$. | 4466 \item $T$ is \code{Type}, $e_1$ is a constant type literal and the class corresp onding to $e_1$ has a static setter named $v=$. |
4212 \end{itemize} | 4467 \end{itemize} |
4213 | 4468 |
4214 | 4469 |
4215 | 4470 |
4216 \LMHash{} | 4471 \LMHash{} |
4217 It is a static type warning if the static type of $e_2$ may not be assigned to t he static type of the formal parameter of the setter $v=$. The static type of the expression $e_1.v$ \code{=} $e_2$ is the static type of $e_2$. | 4472 It is a static type warning if the static type of $e_2$ may not be assigned to t he static type of the formal parameter of the setter $v=$. The static type of the expression $e_1.v$ \code{=} $e_2$ is the static type of $e_2$. |
4218 | 4473 |
4219 \LMHash{} | 4474 \LMHash{} |
4475 Evaluation of an assignment of the form $\SUPER.v$ \code{=} $e$ proceeds as foll ows: | |
4476 | |
4477 \LMHash{} | |
4478 Let $S$ be the superclass of the immediately enclosing class. | |
4479 The expression $e$ is evaluated to an object $o$. Then, the setter $v=$ is look ed up (\ref{getterAndSetterLookup}) in $S$ with respect to the current library. The body of $v=$ is executed with its formal parameter bound to $o$ and \THIS{ } bound to \THIS{}. | |
4480 | |
4481 \LMHash{} | |
4482 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | |
4483 \begin{itemize} | |
4484 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. | |
4485 \item \code{im.memberName} evaluates to the symbol \code{v=}. | |
4486 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o$]}. | |
4487 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
4488 \end{itemize} | |
4489 | |
4490 \LMHash{} | |
4491 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked with argu ment $im$. | |
4492 However, if the implementation found cannot be invoked with a single positional argument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on \THIS{} with argument $im'$, where $im'$ is an instance of \code{Inv ocation} such that : | |
4493 \begin{itemize} | |
4494 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. | |
4495 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. | |
4496 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. | |
4497 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
4498 \end{itemize} | |
4499 | |
4500 \LMHash{} | |
4501 The value of the assignment expression is $o$ irrespective of whether setter loo kup has failed or succeeded. | |
4502 | |
4503 \LMHash{} | |
4504 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 of $S.v$. | |
4505 | |
4506 \LMHash{} | |
4507 It is a static type warning if $S$ does not have an accessible instance setter n amed $v=$ unless $S$ or a superinterface of $S$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \code{dar t:core}. | |
4508 | |
4509 \LMHash{} | |
4510 It is a static type warning if the static type of $e$ may not be assigned to the static type of the formal parameter of the setter $v=$. The static type of th e expression $\SUPER.v$ \code{=} $e$ is the static type of $e$. | |
4511 | |
4512 | |
4513 | |
4514 | |
4515 | |
4516 | |
4517 \LMHash{} | |
4220 Evaluation of an assignment of the form $e_1[e_2]$ \code{=} $e_3$ is equivalent to the evaluation of the expression \code{(a, i, e)\{a.[]=(i, e); \RETURN{} e; \ } ($e_1, e_2, e_3$)}. The static type of the expression $e_1[e_2]$ \code{=} $e_ 3$ is the static type of $e_3$. | 4518 Evaluation of an assignment of the form $e_1[e_2]$ \code{=} $e_3$ is equivalent to the evaluation of the expression \code{(a, i, e)\{a.[]=(i, e); \RETURN{} e; \ } ($e_1, e_2, e_3$)}. The static type of the expression $e_1[e_2]$ \code{=} $e_ 3$ is the static type of $e_3$. |
4221 | 4519 |
4520 \LMHash{} | |
4521 An assignment of the form $\SUPER[e_1]$ \code{=} $e_2$ is equivalent to the expr ession $\SUPER.[e_1]$ \code{=} $e_2$. The static type of the expression $\SUPER [e_1]$ \code{=} $e_2$ is the static type of $e_2$. | |
4522 | |
4523 | |
4222 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map. | 4524 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map. |
4223 | 4525 |
4224 \LMHash{} | 4526 \LMHash{} |
4225 It is a static warning if an assignment of the form $v = e$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer and there is neither a local variable declaration with name $v$ no r setter declaration with name $v=$ in the lexical scope enclosing the assignmen t. | 4527 It is a static warning if an assignment of the form $v = e$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer and there is neither a local variable declaration with name $v$ no r setter declaration with name $v=$ in the lexical scope enclosing the assignmen t. |
4226 | 4528 |
4227 \LMHash{} | 4529 \LMHash{} |
4228 It is a compile-time error to invoke any of the setters of class \cd{Object} on a prefix object (\ref{imports}) or on a constant type literal that is immediate ly followed by the token `.'. | 4530 It is a compile-time error to invoke any of the setters of class \cd{Object} on a prefix object (\ref{imports}) or on a constant type literal that is immediate ly followed by the token `.'. |
4229 | 4531 |
4230 | 4532 |
4231 | 4533 |
4232 \subsubsection{Compound Assignment} | 4534 \subsubsection{Compound Assignment} |
4233 \LMLabel{compoundAssignment} | 4535 \LMLabel{compoundAssignment} |
4234 | 4536 |
4235 \LMHash{} | 4537 \LMHash{} |
4236 A compound assignment of the form $v$ $op\code{=} e$ is equivalent to $v \code{= } v$ $op$ $e$. A compound assignment of the form $C.v$ $op \code{=} e$ is equiva lent to $C.v \code{=} C.v$ $op$ $e$. A compound assignment of the form $e_1.v$ $ op = e_2$ is equivalent to \code{((x) $=>$ x.v = x.v $op$ $e_2$)($e_1$)} where $ x$ is a variable that is not used in $e_2$. A compound assignment of the form $ e_1[e_2]$ $op\code{=} e_3$ is equivalent to | 4538 Evaluation of a compound assignment of the form $v$ {\em ??=} $e$ is equivalent to the evaluation of the expression $((x) => x == \NULL{}$ ? $v=e : x)(v)$ whe re $x$ is a fresh variable that is not used in $e$. Evaluation of a compound ass ignment of the form $C.v$ {\em ??=} $e$, where $C$ is a type literal, is equival ent to the evaluation of the expression $((x) => x == \NULL{}$? $C.v=e: x)(C.v )$ where $x$ is a fresh variable that is not used in $e$. Evaluation of a compou nd assignment of the form $e_1.v$ {\em ??=} $e_2$ is equivalent to the evaluatio n of the expression $((x) =>((y) => y == \NULL{}$ ? $ x.v = e_2: y)(x.v))(e_1)$ where $x$ and $y$ are distinct fresh variables that are not used in $e_2$. Eval uation of a compound assignment of the form $e_1[e_2]$ {\em ??=} $e_3$ is equi valent to the evaluation of the expression |
4539 $((a, i) => ((x) => x == \NULL{}$ ? $a[i] = e_3: x)(a[i]))(e_1, e_2)$ where $x$ , $a$ and $i$ are distinct fresh variables that are not used in $e_3$. Evaluatio n of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is equivalent t o the evaluation of the expression $((x) => x == \NULL{}$ ? $\SUPER.v = e: x)(\ SUPER.v)$ where $x$ is a fresh variable that is not used in $e$. | |
4540 | |
4541 \LMHash{} | |
4542 Evaluation of a compound assignment of the form $e_1?.v$ {\em ??=} $e_2$ is equ ivalent to the evaluation of the expression \code{((x) $=>$ x == \NULL{} ? \NUL L: $x.v ??= e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. | |
4543 | |
4544 | |
4545 \LMHash{} | |
4546 The static type of a compound assignment of the form $v$ {\em ??=} $e$ is the le ast upper bound of the static type of $v$ and the static type of $e$. Exactly t he same static warnings that would be caused by $v = e$ are also generated in th e case of $v$ {\em ??=} $e$. | |
4547 | |
4548 | |
4549 \LMHash{} | |
4550 The static type of a compound assignment of the form $C.v$ {\em ??=} $e$ is th e least upper bound of the static type of $C.v$ and the static type of $e$. Exa ctly the same static warnings that would be caused by $C.v = e$ are also generat ed in the case of $C.v$ {\em ??=} $e$. | |
4551 | |
4552 \LMHash{} | |
4553 The static type of a compound assignment of the form $e_1.v$ {\em ??=} $e_2$ is the least upper bound of the static type of $e_1.v$ and the static type of $e_2 $. Let $T$ be the static type of $e_1$ and let $z$ be a fresh variable of type $ T$. Exactly the same static warnings that would be caused by $z.v = e$ are also generated in the case of $e_1.v$ {\em ??=} $e_2$. | |
4554 | |
4555 \LMHash{} | |
4556 The static type of a compound assignment of the form $e_1[e_2]$ {\em ??=} $e_3$ is the least upper bound of the static type of $e_1[e_2]$ and the static type of $e_3$. Exactly the same static warnings that would be caused by $e_1[e_2] = e _3$ are also generated in the case of $e_1[e_2]$ {\em ??=} $e_3$. | |
4557 | |
4558 \LMHash{} | |
4559 The static type of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is the least upper bound of the static type of $\SUPER.v$ and the static type of $e$. Exactly the same static warnings that would be caused by $\SUPER.v = e$ ar e also generated in the case of $\SUPER.v$ {\em ??=} $e$. | |
4560 | |
4561 \LMHash{} | |
4562 For any other valid operator $op$, a compound assignment of the form $v$ $op\cod e{=} e$ is equivalent to $v \code{=} v$ $op$ $e$. A compound assignment of the f orm $C.v$ $op \code{=} e$ is equivalent to $C.v \code{=} C.v$ $op$ $e$. A compou nd assignment of the form $e_1.v$ $op = e_2$ is equivalent to \code{((x) $=>$ x. v = x.v $op$ $e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. A compound assignment of the form $e_1[e_2]$ $op\code{=} e_3$ is equivalent to | |
4237 \code{((a, i) $=>$ a[i] = a[i] $op$ $e_3$)($e_1, e_2$)} where $a$ and $i$ are a variables that are not used in $e_3$. | 4563 \code{((a, i) $=>$ a[i] = a[i] $op$ $e_3$)($e_1, e_2$)} where $a$ and $i$ are a variables that are not used in $e_3$. |
4238 | 4564 |
4565 \LMHash{} | |
4566 Evaluation of a compound assignment of the form $e_1?.v$ $op = e_2$ is equivalen t to \code{((x) $=>$ x?.v = x.v $op$ $e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. The static type of $e_1?.v$ $op = e_2$ is the static type of $e_1.v$ $op$ $e_2$. Exactly the same static warnings that would be caused by $e_1.v$ $op = e_2$ are also generated in the case of $e_1?.v$ $op = e_2$. | |
4239 | 4567 |
4240 \begin{grammar} | 4568 \begin{grammar} |
4241 {\bf compoundAssignmentOperator:}`*='; | 4569 {\bf compoundAssignmentOperator:}`*='; |
4242 `/='; | 4570 `/='; |
4243 `\~{}/='; | 4571 `\~{}/='; |
4244 `\%='; | 4572 `\%='; |
4245 `+='; | 4573 `+='; |
4246 `-='; | 4574 `-='; |
4247 `{\escapegrammar \lt \lt}='; | 4575 `{\escapegrammar \lt \lt}='; |
4248 `{\escapegrammar \gt \gt}='; | 4576 `{\escapegrammar \gt \gt}='; |
4249 `\&='; | 4577 `\&='; |
4250 `\^{}='; | 4578 `\^{}='; |
4251 `$|$=' | 4579 `$|$='; |
4580 `??='; | |
4252 . | 4581 . |
4253 \end{grammar} | 4582 \end{grammar} |
4254 | 4583 |
4255 | 4584 |
4256 \subsection{ Conditional} | 4585 \subsection{ Conditional} |
4257 \LMLabel{conditional} | 4586 \LMLabel{conditional} |
4258 | 4587 |
4259 \LMHash{} | 4588 \LMHash{} |
4260 A {\em conditional expression} evaluates one of two expressions based on a boole an condition. | 4589 A {\em conditional expression} evaluates one of two expressions based on a boole an condition. |
4261 | 4590 |
4262 \begin{grammar} | 4591 \begin{grammar} |
4263 {\bf conditionalExpression:} | 4592 {\bf conditionalExpression:} |
4264 logicalOrExpression (`?' expressionWithoutCascade `{\escapegrammar :}' expr essionWithoutCascade)? | 4593 ifNullExpression (`?' expressionWithoutCascade `{\escapegrammar :}' express ionWithoutCascade)? |
4265 . % the first branches could top level expressions, it seems, but certainl y NOT the second | 4594 . % the first branches could top level expressions, it seems, but certainl y NOT the second |
4266 \end{grammar} | 4595 \end{grammar} |
4267 | 4596 |
4268 \LMHash{} | 4597 \LMHash{} |
4269 Evaluation of a conditional expression $c$ of the form $e_1 ? e_2 : e_3$ proceed s as follows: | 4598 Evaluation of a conditional expression $c$ of the form $e_1 ? e_2 : e_3$ proceed s as follows: |
4270 | 4599 |
4271 \LMHash{} | 4600 \LMHash{} |
4272 First, $e_1$ is evaluated to an object $o_1$. Then, $o_1$ is subjected to bool ean conversion (\ref{booleanConversion}) producing an object $r$. If $r$ is \TR UE, then the value of $c$ is the result of evaluating the expression $e_2$. Othe rwise the value of $c$ is the result of evaluating the expression $e_3$. | 4601 First, $e_1$ is evaluated to an object $o_1$. Then, $o_1$ is subjected to bool ean conversion (\ref{booleanConversion}) producing an object $r$. If $r$ is \TR UE, then the value of $c$ is the result of evaluating the expression $e_2$. Othe rwise the value of $c$ is the result of evaluating the expression $e_3$. |
4273 | 4602 |
4274 \LMHash{} | 4603 \LMHash{} |
4275 If all of the following hold: | 4604 If all of the following hold: |
4276 \begin{itemize} | 4605 \begin{itemize} |
4277 \item $e_1$ shows that a variable $v$ has type $T$. | 4606 \item $e_1$ shows that a variable $v$ has type $T$. |
4278 \item $v$ is not potentially mutated in $e_2$ or within a closure. | 4607 \item $v$ is not potentially mutated in $e_2$ or within a closure. |
4279 \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$. | 4608 \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$. |
4280 \end{itemize} | 4609 \end{itemize} |
4281 | 4610 |
4282 then the type of $v$ is known to be $T$ in $e_2$. | 4611 then the type of $v$ is known to be $T$ in $e_2$. |
4283 | 4612 |
4284 | 4613 |
4285 \LMHash{} | 4614 \LMHash{} |
4286 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$. | 4615 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$. |
4616 | |
4617 | |
4618 \subsection{If-null Expressions} | |
4619 \label{ifNull} | |
4620 | |
4621 \LMHash{} | |
4622 An {\em if-null expression}evaluates an expression and if the result is \NULL, evaluates another. | |
4623 | |
4624 \begin{grammar} | |
4625 {\bf ifNullExpression:} | |
4626 logicalOrExpression (`??' logicalOrExpression)* | |
4627 \end{grammar} | |
4628 | |
4629 \LMHash{} | |
4630 Evaluation of an if-null expression $e$ of the form $e_1??e_2 $ is equivalent to the evaluation of the expression $((x) => x == \NULL? e_2: x)(e_1)$. The static type of $e$ is least upper bound (\ref{leastUpperBounds}) of the static type of $e_1$ and the static type of $e_2$. | |
4287 | 4631 |
4288 | 4632 |
4289 \subsection{ Logical Boolean Expressions} | 4633 \subsection{ Logical Boolean Expressions} |
4290 \LMLabel{logicalBooleanExpressions} | 4634 \LMLabel{logicalBooleanExpressions} |
4291 | 4635 |
4292 \LMHash{} | 4636 \LMHash{} |
4293 The logical boolean expressions combine boolean objects using the boolean conjun ction and disjunction operators. | 4637 The logical boolean expressions combine boolean objects using the boolean conjun ction and disjunction operators. |
4294 | 4638 |
4295 \begin{grammar} | 4639 \begin{grammar} |
4296 {\bf logicalOrExpression:} | 4640 {\bf logicalOrExpression:} |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4626 | 4970 |
4627 | 4971 |
4628 \subsection{ Postfix Expressions} | 4972 \subsection{ Postfix Expressions} |
4629 \LMLabel{postfixExpressions} | 4973 \LMLabel{postfixExpressions} |
4630 | 4974 |
4631 \LMHash{} | 4975 \LMHash{} |
4632 Postfix expressions invoke the postfix operators on objects. | 4976 Postfix expressions invoke the postfix operators on objects. |
4633 | 4977 |
4634 \begin{grammar} | 4978 \begin{grammar} |
4635 {\bf postfixExpression:}assignableExpression postfixOperator; | 4979 {\bf postfixExpression:}assignableExpression postfixOperator; |
4636 primary selector* | 4980 primary (selector* $|$ ( `\#' ( (identifier `='?) $|$ operator))) |
4637 . | 4981 . |
4638 | 4982 |
4639 {\bf postfixOperator:} | 4983 {\bf postfixOperator:} |
4640 incrementOperator | 4984 incrementOperator |
4641 . | 4985 . |
4642 | 4986 |
4643 {\bf selector:}assignableSelector; | 4987 {\bf selector:}assignableSelector; |
4644 arguments | 4988 arguments |
4645 . | 4989 . |
4646 | 4990 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4704 | 5048 |
4705 \rationale{ | 5049 \rationale{ |
4706 Of course, if assignable expressions always appeared {\em as} the left hand side , one would have no need for their value, and the rules for evaluating them woul d be unnecessary. However, assignable expressions can be subexpressions of othe r expressions and therefore must be evaluated. | 5050 Of course, if assignable expressions always appeared {\em as} the left hand side , one would have no need for their value, and the rules for evaluating them woul d be unnecessary. However, assignable expressions can be subexpressions of othe r expressions and therefore must be evaluated. |
4707 } | 5051 } |
4708 | 5052 |
4709 | 5053 |
4710 | 5054 |
4711 \begin{grammar} | 5055 \begin{grammar} |
4712 | 5056 |
4713 {\bf assignableExpression:}primary (arguments* assignableSelector)+; | 5057 {\bf assignableExpression:}primary (arguments* assignableSelector)+; |
4714 \SUPER{} assignableSelector; | 5058 \SUPER{} unconditionalAssignableSelector; |
4715 identifier | 5059 identifier |
4716 . | 5060 . |
4717 | 5061 |
4718 {\bf assignableSelector:}`[' expression `]'; % again, could be top level | 5062 {\bf unconditionalAssignableSelector:}`[' expression `]'; % again, could be top level |
4719 `{\escapegrammar .}' identifier | 5063 `{\escapegrammar .}' identifier |
5064 . | |
5065 | |
5066 {\bf assignableSelector:} | |
5067 unconditionalAssignableSelector; | |
5068 `{\escapegrammar ?.}' identifier | |
4720 . | 5069 . |
4721 | 5070 |
4722 \end{grammar} | 5071 \end{grammar} |
4723 | 5072 |
5073 | |
4724 \LMHash{} | 5074 \LMHash{} |
4725 An {\em assignable expression} is either: | 5075 An {\em assignable expression} is either: |
4726 \begin{itemize} | 5076 \begin{itemize} |
4727 \item An identifier. | 5077 \item An identifier. |
4728 \item An invocation of a getter (\ref{getters}) or list access operator on an ex pression $e$. | 5078 \item An invocation (possibly conditional) of a getter (\ref{getters}) or list a ccess operator on an expression $e$. |
4729 \item An invocation of a getter or list access operator on \SUPER{}. | 5079 \item An invocation of a getter or list access operator on \SUPER{}. |
4730 \end{itemize} | 5080 \end{itemize} |
4731 | 5081 |
4732 | 5082 |
4733 \LMHash{} | 5083 \LMHash{} |
4734 An assignable expression of the form $id$ is evaluated as an identifier expressi on (\ref{identifierReference}). | 5084 An assignable expression of the form $id$ is evaluated as an identifier expressi on (\ref{identifierReference}). |
4735 | 5085 |
4736 %An assignable expression of the form $e.id(a_1, \ldots, a_n)$ is evaluated as a method invocation (\ref{methodInvocation}). | 5086 %An assignable expression of the form $e.id(a_1, \ldots, a_n)$ is evaluated as a method invocation (\ref{methodInvocation}). |
4737 | 5087 |
4738 \LMHash{} | 5088 \LMHash{} |
4739 An assignable expression of the form $e.id$ is evaluated as a property extractio n (\ref{propertyExtraction}). | 5089 An assignable expression of the form $e.id$ or $e?.id$ is evaluated as a propert y extraction (\ref{propertyExtraction}). |
4740 | 5090 |
4741 \LMHash{} | 5091 \LMHash{} |
4742 An assignable expression of the form \code{$e_1$[$e_2$]} is evaluated as a metho d invocation of the operator method \code{[]} on $e_1$ with argument $e_2$. | 5092 An assignable expression of the form \code{$e_1$[$e_2$]} is evaluated as a metho d invocation of the operator method \code{[]} on $e_1$ with argument $e_2$. |
4743 | 5093 |
4744 \LMHash{} | 5094 \LMHash{} |
4745 An assignable expression of the form \code{\SUPER{}.id} is evaluated as a prope rty extraction. | 5095 An assignable expression of the form \code{\SUPER{}.id} is evaluated as a prope rty extraction. |
4746 | 5096 |
4747 \LMHash{} | 5097 \LMHash{} |
4748 An assignable expression of the form \code{\SUPER{}[$e_2$]} is equivalent to the method invocation \code{\SUPER{}.[]($e_2$)}. | 5098 An assignable expression of the form \code{\SUPER{}[$e_2$]} is equivalent to the method invocation \code{\SUPER{}.[]($e_2$)}. |
4749 | 5099 |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5660 A try statement \TRY{} $s_1$ $on-catch_1 \ldots on-catch_n$ \FINALLY{} $s_f$ d efines an exception handler $h$ that executes as follows: | 6010 A try statement \TRY{} $s_1$ $on-catch_1 \ldots on-catch_n$ \FINALLY{} $s_f$ d efines an exception handler $h$ that executes as follows: |
5661 | 6011 |
5662 \LMHash{} | 6012 \LMHash{} |
5663 The \ON{}-\CATCH{} clauses are examined in order, starting with $catch_1$, until either an \ON{}-\CATCH{} clause that matches the current exception (\ref{throw} ) is found, or the list of \ON{}-\CATCH{} clauses has been exhausted. If an \ON{ }-\CATCH{} clause $on-catch_k$ is found, then $p_{k1}$ is bound to the current e xception, $p_{k2}$, if declared, is bound to the active stack trace, and then $catch_k$ is executed. If no \ON{}-\CATCH{} clause is found, the \FINALLY{} clau se is executed. Then, execution resumes at the end of the try statement. | 6013 The \ON{}-\CATCH{} clauses are examined in order, starting with $catch_1$, until either an \ON{}-\CATCH{} clause that matches the current exception (\ref{throw} ) is found, or the list of \ON{}-\CATCH{} clauses has been exhausted. If an \ON{ }-\CATCH{} clause $on-catch_k$ is found, then $p_{k1}$ is bound to the current e xception, $p_{k2}$, if declared, is bound to the active stack trace, and then $catch_k$ is executed. If no \ON{}-\CATCH{} clause is found, the \FINALLY{} clau se is executed. Then, execution resumes at the end of the try statement. |
5664 | 6014 |
5665 | 6015 |
5666 \LMHash{} | 6016 \LMHash{} |
5667 A finally clause \FINALLY{} $s$ defines an exception handler $h$ that executes a s follows: | 6017 A finally clause \FINALLY{} $s$ defines an exception handler $h$ that executes a s follows: |
5668 | 6018 |
5669 \LMHash{} | 6019 \LMHash{} |
5670 Let $r$ be the current return value (\ref{return}). Then the current return valu e becomes undefined. Any open streams associated with any asynchronous for loops (\ref{asynchronousFor-in}) and yield-each (\ref{yieldEach}) statements executin g within the dynamic scope of $h$ are canceled. | 6020 Let $r$ be the current return value (\ref{return}). Then the current return valu e becomes undefined. Any open streams associated with any asynchronous for loops (\ref{asynchronousFor-in}) and yield-each (\ref{yieldEach}) statements executin g within the dynamic scope of $h$ are canceled, in the order of their nesting, i nnermost first. |
5671 | 6021 |
5672 \rationale{ | 6022 \rationale{ |
5673 Streams left open by for loops that were escaped for whatever reason would be ca nceled at function termination, but it is best to cancel them as soon as possibl e. | 6023 Streams left open by for loops that were escaped for whatever reason would be ca nceled at function termination, but it is best to cancel them as soon as possibl e. |
5674 } | 6024 } |
5675 | 6025 |
5676 \LMHash{} | 6026 \LMHash{} |
5677 Then the \FINALLY{} clause is executed. Let $m$ be the immediately enclosing fun ction. If $r$ is defined then the current return value is set to $r$ and then: | 6027 Then the \FINALLY{} clause is executed. Let $m$ be the immediately enclosing fun ction. If $r$ is defined then the current return value is set to $r$ and then: |
5678 \begin{itemize} | 6028 \begin{itemize} |
5679 \item | 6029 \item |
5680 if there is a dynamically enclosing error handler $g$ defined by a \FINALLY{} c lause in $m$, control is transferred to $g$. | 6030 if there is a dynamically enclosing error handler $g$ defined by a \FINALLY{} c lause in $m$, control is transferred to $g$. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5866 \begin{grammar} | 6216 \begin{grammar} |
5867 {\bf breakStatement:} | 6217 {\bf breakStatement:} |
5868 \BREAK{} identifier? `{\escapegrammar ;}' | 6218 \BREAK{} identifier? `{\escapegrammar ;}' |
5869 . | 6219 . |
5870 \end{grammar} | 6220 \end{grammar} |
5871 | 6221 |
5872 \LMHash{} | 6222 \LMHash{} |
5873 Let $s_b$ be a \BREAK{} statement. If $s_b$ is of the form \code{\BREAK{} $L$;} , then let $s_E$ be the the innermost labeled statement with label $L$ enclosing $s_b$. If $s_b$ is of the form \code{\BREAK{};}, then let $s_E$ be the the inn ermost \DO{} (\ref{do}), \FOR{} (\ref{for}), \SWITCH{} (\ref{switch}) or \WHILE {} (\ref{while}) statement enclosing $s_b$. It is a compile-time error if no su ch statement $s_E$ exists within the innermost function in which $s_b$ occurs. Furthermore, let $s_1, \ldots, s_n$ be those \TRY{} statements that are both en closed in $s_E$ and that enclose $s_b$, and that have a \FINALLY{} clause. Last ly, let $f_j$ be the \FINALLY{} clause of $s_j, 1 \le j \le n$. Executing $s_ b$ first executes $f_1, \ldots, f_n$ in innermost-clause-first order and then terminates $s_E$. | 6223 Let $s_b$ be a \BREAK{} statement. If $s_b$ is of the form \code{\BREAK{} $L$;} , then let $s_E$ be the the innermost labeled statement with label $L$ enclosing $s_b$. If $s_b$ is of the form \code{\BREAK{};}, then let $s_E$ be the the inn ermost \DO{} (\ref{do}), \FOR{} (\ref{for}), \SWITCH{} (\ref{switch}) or \WHILE {} (\ref{while}) statement enclosing $s_b$. It is a compile-time error if no su ch statement $s_E$ exists within the innermost function in which $s_b$ occurs. Furthermore, let $s_1, \ldots, s_n$ be those \TRY{} statements that are both en closed in $s_E$ and that enclose $s_b$, and that have a \FINALLY{} clause. Last ly, let $f_j$ be the \FINALLY{} clause of $s_j, 1 \le j \le n$. Executing $s_ b$ first executes $f_1, \ldots, f_n$ in innermost-clause-first order and then terminates $s_E$. |
5874 | 6224 |
5875 \LMHash{} | 6225 \LMHash{} |
5876 If $s_E$ is an asynchronous for loop (\ref{asynchronousFor-in}), its associated stream subscription is canceled. Furthermore, let $a_k$ be the set of asynchrono us for loops and yield-each statements (\ref{yieldEach}) enclosing $s_b$ that a re enclosed in $s_E , 1 \le k \le m$. The stream subscriptions associated with $a_j$ are canceled, $1 \le j \le m$. | 6226 If $s_E$ is an asynchronous for loop (\ref{asynchronousFor-in}), its associated stream subscription is canceled. Furthermore, let $a_k$ be the set of asynchrono us for loops and yield-each statements (\ref{yieldEach}) enclosing $s_b$ that a re enclosed in $s_E , 1 \le k \le m$, where $a_k$ is enclosed in $a_{k+1}$. Th e stream subscriptions associated with $a_j$ are canceled, $1 \le j \le m$, inne rmost first, so that $a_j$ is canceled before $a_{j+1}$. |
5877 | 6227 |
5878 | 6228 |
5879 | 6229 |
5880 \subsection{ Continue} | 6230 \subsection{ Continue} |
5881 \LMLabel{continue} | 6231 \LMLabel{continue} |
5882 | 6232 |
5883 \LMHash{} | 6233 \LMHash{} |
5884 The {\em continue statement} consists of the reserved word \CONTINUE{} and an op tional label (\ref{labels}). | 6234 The {\em continue statement} consists of the reserved word \CONTINUE{} and an op tional label (\ref{labels}). |
5885 | 6235 |
5886 \begin{grammar} | 6236 \begin{grammar} |
5887 {\bf continueStatement:} | 6237 {\bf continueStatement:} |
5888 \CONTINUE{} identifier? `{\escapegrammar ;}' | 6238 \CONTINUE{} identifier? `{\escapegrammar ;}' |
5889 . | 6239 . |
5890 \end{grammar} | 6240 \end{grammar} |
5891 | 6241 |
5892 \LMHash{} | 6242 \LMHash{} |
5893 Let $s_c$ be a \CONTINUE{} statement. If $s_c$ is of the form \code{\CONTINUE{ } $L$;}, then let $s_E$ be the the innermost labeled \DO{} (\ref{do}), \FOR{} (\ ref{for}) or \WHILE{} (\ref{while}) statement or case clause with label $L$ encl osing $s_c$. If $s_c$ is of the form \code{\CONTINUE{};} then let $s_E$ be the the innermost \DO{} (\ref{do}), \FOR{} (\ref{for}) or \WHILE{} (\ref{while}) st atement enclosing $s_c$. It is a compile-time error if no such statement or cas e clause $s_E$ exists within the innermost function in which $s_c$ occurs. Fur thermore, let $s_1, \ldots, s_n$ be those \TRY{} statements that are both enclos ed in $s_E$ and that enclose $s_c$, and that have a \FINALLY{} clause. Lastly, let $f_j$ be the \FINALLY{} clause of $s_j, 1 \le j \le n$. Executing $s_c$ f irst executes $f_1, \ldots, f_n$ in innermost-clause-first order. Then, if $s_ E$ is a case clause, control is transferred to the case clause. Otherwise, $s_E$ is necessarily a loop and execution resumes after the last statement in the loo p body. | 6243 Let $s_c$ be a \CONTINUE{} statement. If $s_c$ is of the form \code{\CONTINUE{ } $L$;}, then let $s_E$ be the the innermost labeled \DO{} (\ref{do}), \FOR{} (\ ref{for}) or \WHILE{} (\ref{while}) statement or case clause with label $L$ encl osing $s_c$. If $s_c$ is of the form \code{\CONTINUE{};} then let $s_E$ be the the innermost \DO{} (\ref{do}), \FOR{} (\ref{for}) or \WHILE{} (\ref{while}) st atement enclosing $s_c$. It is a compile-time error if no such statement or cas e clause $s_E$ exists within the innermost function in which $s_c$ occurs. Fur thermore, let $s_1, \ldots, s_n$ be those \TRY{} statements that are both enclos ed in $s_E$ and that enclose $s_c$, and that have a \FINALLY{} clause. Lastly, let $f_j$ be the \FINALLY{} clause of $s_j, 1 \le j \le n$. Executing $s_c$ f irst executes $f_1, \ldots, f_n$ in innermost-clause-first order. Then, if $s_ E$ is a case clause, control is transferred to the case clause. Otherwise, $s_E$ is necessarily a loop and execution resumes after the last statement in the loo p body. |
5894 | 6244 |
5895 \commentary{ | 6245 \commentary{ |
5896 In a while loop, that would be the boolean expression before the body. In a do loop, it would be the boolean expression after the body. In a for loop, it would be the increment clause. In other words, execution continues to the next itera tion of the loop. | 6246 In a while loop, that would be the boolean expression before the body. In a do loop, it would be the boolean expression after the body. In a for loop, it would be the increment clause. In other words, execution continues to the next itera tion of the loop. |
5897 } | 6247 } |
5898 | 6248 |
5899 \LMHash{} | 6249 \LMHash{} |
5900 If $s_E$ is an asynchronous for loop (\ref{asynchronousFor-in}), let $a_k$ be t he set of asynchronous for loops and yield-each statements (\ref{yieldEach}) enc losing $s_c$ that are enclosed in $s_E , 1 \le k \le m$. The stream subscripti ons associated with $a_j$ are canceled, $1 \le j \le m$. | 6250 If $s_E$ is an asynchronous for loop (\ref{asynchronousFor-in}), let $a_k$ be t he set of asynchronous for loops and yield-each statements (\ref{yieldEach}) enc losing $s_c$ that are enclosed in $s_E , 1 \le k \le m$, where $a_k$ is enclosed in $a_{k+1}$. The stream subscriptions associated with $a_j$ are canceled, $1 \le j \le m$, innermost first, so that $a_j$ is canceled before $a_{j+1}$. |
5901 | 6251 |
5902 \subsection{ Yield and Yield-Each} | 6252 \subsection{ Yield and Yield-Each} |
5903 \LMLabel{yieldAndYieldEach} | 6253 \LMLabel{yieldAndYieldEach} |
5904 | 6254 |
5905 \subsubsection{ Yield} | 6255 \subsubsection{ Yield} |
5906 \LMLabel{yield} | 6256 \LMLabel{yield} |
5907 | 6257 |
5908 \LMHash{} | 6258 \LMHash{} |
5909 The {\em yield statement} adds an element to the result of a generator function (\ref{functions}). | 6259 The {\em yield statement} adds an element to the result of a generator function (\ref{functions}). |
5910 | 6260 |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7215 \LMHash{} | 7565 \LMHash{} |
7216 Operator precedence is given implicitly by the grammar. | 7566 Operator precedence is given implicitly by the grammar. |
7217 | 7567 |
7218 \commentary{The following non-normative table may be helpful | 7568 \commentary{The following non-normative table may be helpful |
7219 \newline | 7569 \newline |
7220 | 7570 |
7221 \begin{tabular}{| r | r | r | r |} | 7571 \begin{tabular}{| r | r | r | r |} |
7222 \hline | 7572 \hline |
7223 Description & Operator & Associativity & Precedence \\ | 7573 Description & Operator & Associativity & Precedence \\ |
7224 \hline | 7574 \hline |
7225 Unary postfix & ., e++, e--, e1[e2], e1() , () & None & 15 \\ | 7575 Unary postfix & ., ?., e++, e--, e1[e2], e1() , () & None & 16 \\ |
7226 \hline | 7576 \hline |
7227 Unary prefix & -e, !e, \~{}e, ++e, --e & None & 14\\ | 7577 Unary prefix & -e, !e, \~{}e, ++e, --e & None & 15\\ |
7228 \hline | 7578 \hline |
7229 Multiplicative & *, /, \~/, \% & Left & 13\\ | 7579 Multiplicative & *, /, \~/, \% & Left & 14\\ |
7230 \hline | 7580 \hline |
7231 Additive & +, - & Left & 12\\ | 7581 Additive & +, - & Left & 13\\ |
7232 \hline | 7582 \hline |
7233 Shift & $<<$, $>>$& Left & 11\\ | 7583 Shift & $<<$, $>>$& Left & 12\\ |
7234 \hline | 7584 \hline |
7235 Bitwise AND & \& & Left & 10\\ | 7585 Bitwise AND & \& & Left & 11\\ |
7236 \hline | 7586 \hline |
7237 Bitwise XOR & \^{} & Left & 9\\ | 7587 Bitwise XOR & \^{} & Left & 10\\ |
7238 \hline | 7588 \hline |
7239 Bitwise Or & $|$ & Left & 8\\ | 7589 Bitwise Or & $|$ & Left & 9\\ |
7240 \hline | 7590 \hline |
7241 Relational & $<$, $>$, $<=$, $>=$, \AS{}, \IS{}, \IS{}! & None & 7\\ | 7591 Relational & $<$, $>$, $<=$, $>=$, \AS{}, \IS{}, \IS{}! & None & 8\\ |
7242 \hline | 7592 \hline |
7243 Equality & ==, != & None & 6\\ | 7593 Equality & ==, != & None & 7\\ |
7244 \hline | 7594 \hline |
7245 Logical AND & \&\& & Left & 5\\ | 7595 Logical AND & \&\& & Left & 6\\ |
7246 \hline | 7596 \hline |
7247 Logical Or & $||$ & Left & 4\\ | 7597 Logical Or & $||$ & Left & 5\\ |
7598 \hline | |
7599 If-null & ?? & Left & 4\\ | |
7248 \hline | 7600 \hline |
7249 Conditional & e1? e2: e3 & Right & 3\\ | 7601 Conditional & e1? e2: e3 & Right & 3\\ |
7250 \hline | 7602 \hline |
7251 Cascade & .. & Left & 2\\ | 7603 Cascade & .. & Left & 2\\ |
7252 \hline | 7604 \hline |
7253 Assignment & =, *=, /=, +=, -= ,\&=, \^{}= etc. & Right & 1\\ | 7605 Assignment & =, *=, /=, +=, -= ,\&=, \^{}= etc. & Right & 1\\ |
7254 \hline | 7606 \hline |
7255 \end{tabular} | 7607 \end{tabular} |
7256 } | 7608 } |
7257 %\subsection{Glossary} | 7609 %\subsection{Glossary} |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7421 | 7773 |
7422 The invariant that each normative paragraph is associated with a line | 7774 The invariant that each normative paragraph is associated with a line |
7423 containing the text \LMHash{} should be maintained. Extra occurrences | 7775 containing the text \LMHash{} should be maintained. Extra occurrences |
7424 of \LMHash{} can be added if needed, e.g., in order to make | 7776 of \LMHash{} can be added if needed, e.g., in order to make |
7425 individual \item{}s in itemized lists addressable. Each \LM.. command | 7777 individual \item{}s in itemized lists addressable. Each \LM.. command |
7426 must occur on a separate line. \LMHash{} must occur immediately | 7778 must occur on a separate line. \LMHash{} must occur immediately |
7427 before the associated paragraph, and \LMLabel must occur immediately | 7779 before the associated paragraph, and \LMLabel must occur immediately |
7428 after the associated \section{}, \subsection{} etc. | 7780 after the associated \section{}, \subsection{} etc. |
7429 | 7781 |
7430 ---------------------------------------------------------------------- | 7782 ---------------------------------------------------------------------- |
OLD | NEW |