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. |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Clever :)
eernst
2015/03/26 22:38:50
I guess 'property extraction' covers more than int
| |
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)?; | |
2353 \CONST{} type `\#' (`{\escapegrammar .}' identifier)?; | |
Paul Berry
2015/03/26 18:55:58
What's the justification for having tear-offs of b
Lasse Reichstein Nielsen
2015/03/26 19:18:57
Ack, yes, forgot to comment on that.
If there is n
eernst
2015/03/26 22:38:51
Did you have to add the periods here to make the g
gbracha
2015/03/26 23:21:22
You mean we haven't stated that a const T# is a co
| |
2352 constObjectExpression; | 2354 constObjectExpression; |
2353 `(' expression `)' | 2355 `(' expression `)' |
2354 . | 2356 . |
2355 | 2357 |
2356 \end{grammar} | 2358 \end{grammar} |
2357 | 2359 |
2358 \LMHash{} | 2360 \LMHash{} |
2359 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$. | 2361 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$. |
2360 | 2362 |
2361 \commentary{ | 2363 \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. | 3520 \item If $s$ has been canceled then its cancellation future is completed with $x$ as an error. |
3519 \end{itemize} | 3521 \end{itemize} |
3520 \item $s$ is closed. | 3522 \item $s$ is closed. |
3521 \end{itemize} | 3523 \end{itemize} |
3522 | 3524 |
3523 \rationale{ | 3525 \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. | 3526 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 } | 3527 } |
3526 | 3528 |
3527 \LMHash{} | 3529 \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. | 3530 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 | 3531 |
3530 \rationale{Such streams may be left open by for loops that were escaped when an exception was thrown within them for example. | 3532 \rationale{Such streams may be left open by for loops that were escaped when an exception was thrown within them for example. |
3531 } | 3533 } |
3532 | 3534 |
3535 %\LMHash{} | |
3536 %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/26 10:38:48
Uncomment?
Also maybe: "stream is canceled" -> "st
gbracha
2015/03/26 23:21:22
The VM team has concerns with this. If it's absenc
| |
3537 | |
3533 \LMHash{} | 3538 \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. | 3539 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 | 3540 |
3536 | 3541 |
3537 \commentary{ | 3542 \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}. | 3543 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 } | 3544 } |
3540 | 3545 |
3541 \LMHash{} | 3546 \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. | 3547 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3689 | 3694 |
3690 | 3695 |
3691 \subsubsection{ Function Expression Invocation} | 3696 \subsubsection{ Function Expression Invocation} |
3692 \LMLabel{functionExpressionInvocation} | 3697 \LMLabel{functionExpressionInvocation} |
3693 | 3698 |
3694 \LMHash{} | 3699 \LMHash{} |
3695 A function expression invocation $i$ has the form | 3700 A function expression invocation $i$ has the form |
3696 | 3701 |
3697 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, | 3702 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, |
3698 | 3703 |
3699 where $e_f$ is an expression. If $e_f$ is an identifier $id$, then $id$ must nec essarily denote a local function, a library function, a library or static getter or a variable as described above, or $i$ is not considered a function expressio n invocation. If $e_f$ is a property extraction expression (\ref{propertyExtract ion}), then $i$ is is not a function expression invocation and is instead recogn ized as an ordinary method invocation (\ref{ordinaryInvocation}). | 3704 where $e_f$ is an expression. If $e_f$ is an identifier $id$, then $id$ must nec essarily denote a local function, a library function, a library or static getter or a variable as described above, or $i$ is not considered a function expressio n invocation. If $e_f$ is a property extraction expression (\ref{propertyExtract ion}), then $i$ is is not a function expression invocation and is instead recogn ized as an ordinary method invocation (\ref{ordinaryInvocation}). |
Paul Berry
2015/03/26 15:07:21
We need to clarify that the last sentence applies
gbracha
2015/03/26 23:21:22
Yes, I think that is a good idea. Done.
| |
3700 | 3705 |
3701 \commentary{ | 3706 \commentary{ |
3702 \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on objec t \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed b y a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, t he two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invoc ation} passed to \code{noSuchMethod()} would describe a call to a method \code{$ b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b $} (with no arguments) in the latter. | 3707 \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on objec t \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed b y a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, t he two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invoc ation} passed to \code{noSuchMethod()} would describe a call to a method \code{$ b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b $} (with no arguments) in the latter. |
3703 } | 3708 } |
3704 | 3709 |
3705 \LMHash{} | 3710 \LMHash{} |
3706 Otherwise: | 3711 Otherwise: |
3707 | 3712 |
3708 A function expression invocation $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldot s , x_{n+k}: a_{n+k})$ is equivalent to $e_f.call(a_1, \ldots , a_n, x_{n+1}: a_ {n+1}, \ldots , x_{n+k}: a_{n+k})$. | 3713 A function expression invocation $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldot s , x_{n+k}: a_{n+k})$ is equivalent to $e_f.call(a_1, \ldots , a_n, x_{n+1}: a_ {n+1}, \ldots , x_{n+k}: a_{n+k})$. |
3709 | 3714 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3768 \subsection{ Method Invocation} | 3773 \subsection{ Method Invocation} |
3769 \LMLabel{methodInvocation} | 3774 \LMLabel{methodInvocation} |
3770 | 3775 |
3771 \LMHash{} | 3776 \LMHash{} |
3772 Method invocation can take several forms as specified below. | 3777 Method invocation can take several forms as specified below. |
3773 | 3778 |
3774 \subsubsection{Ordinary Invocation} | 3779 \subsubsection{Ordinary Invocation} |
3775 \LMLabel{ordinaryInvocation} | 3780 \LMLabel{ordinaryInvocation} |
3776 | 3781 |
3777 \LMHash{} | 3782 \LMHash{} |
3778 An ordinary method invocation $i$ has the form | 3783 An ordinary method invocation can be {\em conditional} or {\em unconditional}. |
3784 | |
3785 \LMHash{} | |
3786 Evaluation of a {\em conditional ordinary method invocation} $e$ of the form | |
3787 | |
3788 \LMHash{} | |
3789 $o?.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ | |
3790 | |
3791 \LMHash{} | |
3792 is equivalent to the evaluation of the expression | |
3793 | |
3794 \LMHash{} | |
3795 $((x) => x == \NULL ? \NULL : x.im(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}))(o)$. | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
x.im -> x.m
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Does this correctly give static warnings if o.m do
Paul Berry
2015/03/26 15:07:21
Unfortunately Lasse's proposed rewrite would intro
gbracha
2015/03/26 23:21:21
Done.
gbracha
2015/03/26 23:21:23
No, because checked mode would behave differently.
| |
3796 | |
3797 \LMHash{} | |
3798 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})$. | |
3799 | |
3800 \LMHash{} | |
3801 An {\em unconditional ordinary method invocation} $i$ has the form | |
3779 | 3802 |
3780 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. | 3803 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. |
3781 | 3804 |
3782 \LMHash{} | 3805 \LMHash{} |
3783 Evaluation of an ordinary method invocation $i$ of the form | 3806 Evaluation of an unconditional ordinary method invocation $i$ of the form |
3784 | 3807 |
3785 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ | 3808 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ |
3786 | 3809 |
3787 proceeds as follows: | 3810 proceeds as follows: |
3788 | 3811 |
3789 \LMHash{} | 3812 \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$. | 3813 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 | 3814 |
3792 \LMHash{} | 3815 \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$. | 3816 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3839 \NEW{} Perverse.unknownMethod(); | 3862 \NEW{} Perverse.unknownMethod(); |
3840 \end{code} | 3863 \end{code} |
3841 | 3864 |
3842 \commentary{Notice that the wording carefully avoids re-evaluating the receiver $o$ and the arguments $a_i$. } | 3865 \commentary{Notice that the wording carefully avoids re-evaluating the receiver $o$ and the arguments $a_i$. } |
3843 | 3866 |
3844 \LMHash{} | 3867 \LMHash{} |
3845 Let $T$ be the static type of $o$. It is a static type warning if $T$ does not have an accessible (\ref{privacy}) instance member named $m$ unless either: | 3868 Let $T$ be the static type of $o$. It is a static type warning if $T$ does not have an accessible (\ref{privacy}) instance member named $m$ unless either: |
3846 \begin{itemize} | 3869 \begin{itemize} |
3847 \item | 3870 \item |
3848 $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 | 3871 $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 |
3849 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static getter named $m$. | 3872 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static getter named $m$. |
Paul Berry
2015/03/26 15:07:21
Considering the commentary you've added at line 49
gbracha
2015/03/26 23:21:22
The intent was that it would produce a static warn
| |
3850 \end{itemize} | 3873 \end{itemize} |
3851 | 3874 |
3852 \LMHash{} | 3875 \LMHash{} |
3853 If $T.m$ exists, it is a static type warning if the type $F$ of $T.m$ may not b e assigned to a function type. If $T.m$ does not exist, or if $F$ is not a funct ion type, the static type of $i$ is \DYNAMIC{}; otherwise the static type of $i$ is the declared return type of $F$. | 3876 If $T.m$ exists, it is a static type warning if the type $F$ of $T.m$ may not b e assigned to a function type. If $T.m$ does not exist, or if $F$ is not a funct ion type, the static type of $i$ is \DYNAMIC{}; otherwise the static type of $i$ is the declared return type of $F$. |
3854 | 3877 |
3855 \LMHash{} | 3878 \LMHash{} |
3856 It is a compile-time error to invoke any of the methods of class \cd{Object} on a prefix object (\ref{imports}) or on a constant type literal that is immediate ly followed by the token `.'. | 3879 It is a compile-time error to invoke any of the methods of class \cd{Object} on a prefix object (\ref{imports}) or on a constant type literal that is immediate ly followed by the token `.'. |
3857 | 3880 |
3858 | 3881 |
3859 \subsubsection{Cascaded Invocations} | 3882 \subsubsection{Cascaded Invocations} |
3860 \LMLabel{cascadedInvocations} | 3883 \LMLabel{cascadedInvocations} |
3861 | 3884 |
3862 \LMHash{} | 3885 \LMHash{} |
3863 A {\em cascaded method invocation} has the form {\em e..suffix} | 3886 A {\em cascaded method invocation} has the form {\em e..suffix} |
3864 where $e$ is an expression and {\em suffix} is a sequence of operator, method, g etter or setter invocations. | 3887 where $e$ is an expression and {\em suffix} is a sequence of operator, method, g etter or setter invocations. |
3865 | 3888 |
3866 \begin{grammar} | 3889 \begin{grammar} |
3867 {\bf cascadeSection:} | 3890 {\bf cascadeSection:} |
3868 `{\escapegrammar ..}' (cascadeSelector arguments*) (assignableSelector arg uments*)* (assignmentOperator expressionWithoutCascade)? | 3891 `{\escapegrammar ..}' (cascadeSelector arguments*) (assignableSelector arg uments*)* (assignmentOperator expressionWithoutCascade)? |
3869 . | 3892 . |
3870 | 3893 |
3871 {\bf cascadeSelector:}`[' expression `]'; | 3894 {\bf cascadeSelector:}`[' expression `]'; |
3872 identifier | 3895 identifier |
3873 . | 3896 . |
3874 \end{grammar} | 3897 \end{grammar} |
3875 | 3898 |
3876 \LMHash{} | 3899 \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$)}. | 3900 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 | 3901 |
3902 \rationale{ | |
3903 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$)}. | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Makes sense. We have cascades so you can write x..
eernst
2015/03/26 22:38:51
Having x?..foo?..bar it's natural to consider x?..
| |
3904 | |
3905 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}. | |
3906 } | |
3907 | |
3879 \subsubsection{Super Invocation} | 3908 \subsubsection{Super Invocation} |
3880 \LMLabel{superInvocation} | 3909 \LMLabel{superInvocation} |
3881 | 3910 |
3882 \LMHash{} | 3911 \LMHash{} |
3883 A super method invocation $i$ has the form | 3912 A super method invocation $i$ has the form |
3884 | 3913 |
3885 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. | 3914 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. |
3886 | 3915 |
3887 \LMHash{} | 3916 \LMHash{} |
3888 Evaluation of $i$ proceeds as follows: | 3917 Evaluation of $i$ proceeds as follows: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3939 | 3968 |
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. | 3969 \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 } | 3970 } |
3942 | 3971 |
3943 | 3972 |
3944 | 3973 |
3945 \subsection{ Property Extraction} | 3974 \subsection{ Property Extraction} |
3946 \LMLabel{propertyExtraction} | 3975 \LMLabel{propertyExtraction} |
3947 | 3976 |
3948 \LMHash{} | 3977 \LMHash{} |
3949 {\em Property extraction} allows for a member of an object to be concisely extra cted from the object. | 3978 {\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: | 3979 A property extraction can be either: |
3951 \begin{enumerate} | 3980 \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 | 3981 \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. | 3982 \item A {\em getter invocation} which returns the result of invoking of a getter method. |
3954 \end{enumerate} | 3983 \end{enumerate} |
3955 | 3984 |
3956 \LMHash{} | 3985 \LMHash{} |
3986 Property extraction takes several syntactic forms: $e.m$ (\ref{getterAccessAndMe thodExtraction}), $\SUPER.m$ (\ref{superGetterAccessAndMethodClosurization}), $e \#m$ (\ref{generalClosurization}), $\NEW{}$ $T\#m$ (\ref{namedConstructorExtract ion}), $\NEW{}$ $T\#$ (\ref{anonymousConstructorExtraction}) and $\SUPER\#m$ (\r ef{generalSuperPropertyExtraction}), where $e$ is an expression, $m$ is an ident ifier optionally followed by an equal sign and $T$ is a type. | |
Paul Berry
2015/03/26 15:07:21
As I mentioned on line 3704, I think the syntactic
gbracha
2015/03/26 23:21:22
super?.m makes no sense; I've altered the grammar
| |
3987 | |
3988 \subsubsection{Getter Access and Method Extraction} | |
3989 \LMLabel{getterAccessAndMethodExtraction} | |
3990 | |
3991 \LMHash{} | |
3957 Evaluation of a property extraction $i$ of the form $e.m$ proceeds as follows: | 3992 Evaluation of a property extraction $i$ of the form $e.m$ proceeds as follows: |
3958 | 3993 |
3959 \LMHash{} | 3994 \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$. | 3995 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}). |
3996 | |
3997 \commentary { | |
3998 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. | |
3999 } | |
3961 | 4000 |
3962 \LMHash{} | 4001 \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. | 4002 Otherwise, $i$ is a getter invocation. Let $f$ be the result of looking up |
4003 (\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 | 4004 |
3965 \LMHash{} | 4005 \LMHash{} |
3966 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 4006 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} | 4007 \begin{itemize} |
3968 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. | 4008 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. |
3969 \item \code{im.memberName} evaluates to \code{'m'}. | 4009 \item \code{im.memberName} evaluates to \code{'m'}. |
3970 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . | 4010 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . |
3971 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 4011 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3972 \end{itemize} | 4012 \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 : | 4013 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} | 4014 \begin{itemize} |
3975 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 4015 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. |
3976 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 4016 \item \code{im'.memberName} evaluates to \code{noSuchMethod}. |
3977 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 4017 \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{} \{\}}. | 4018 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3979 \end{itemize} | 4019 \end{itemize} |
3980 | 4020 |
3981 and the result of this latter invocation is the result of evaluating $i$. | 4021 and the result of this latter invocation is the result of evaluating $i$. |
3982 | 4022 |
3983 \LMHash{} | 4023 \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. | 4024 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 | 4025 |
3986 \commentary { | 4026 \commentary { |
3987 This precludes \code{int.toString} but not \code{(int).toString} because in the latter case, $e$ is a parenthesized expression. | 4027 This precludes \code{int.toString} but not \code{(int).toString} because in the latter case, $e$ is a parenthesized expression. |
3988 } | 4028 } |
3989 | 4029 |
3990 \LMHash{} | 4030 \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: | 4031 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} | 4032 \begin{itemize} |
3993 \item | 4033 \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 | 4034 $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$. | 4035 \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} | 4036 \end{itemize} |
3997 | 4037 |
3998 \LMHash{} | 4038 \LMHash{} |
3999 If $i$ is a getter invocation, the static type of $i$ is: | 4039 The static type of $i$ is: |
4000 \begin{itemize} | 4040 \begin{itemize} |
4001 \item The declared return type of $T.m$, if $T.m$ exists. | 4041 \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$. | 4042 \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$. |
4043 \item The static type of function $T.m$ if $T$ has an accessible instance method named $m$. | |
4044 \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. | 4045 \item The type \DYNAMIC{} otherwise. |
4004 \end{itemize} | 4046 \end{itemize} |
4005 | 4047 |
4006 \LMHash{} | 4048 |
4007 If $i$ is a closurization, its static type is as described in section \ref{closu rization}. | 4049 \subsubsection{Super Getter Access and Method Closurization} |
4050 \LMLabel{superGetterAccessAndMethodClosurization} | |
4008 | 4051 |
4009 \LMHash{} | 4052 \LMHash{} |
4010 Evaluation of a property extraction $i$ of the form $\SUPER.m$ proceeds as follo ws: | 4053 Evaluation of a property extraction $i$ of the form $\SUPER.m$ proceeds as follo ws: |
4011 | 4054 |
4012 \LMHash{} | 4055 \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}). | 4056 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 | 4057 |
4015 \LMHash{} | 4058 \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. | 4059 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 | 4060 |
4018 \LMHash{} | 4061 \LMHash{} |
4019 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 4062 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} | 4063 \begin{itemize} |
4021 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. | 4064 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. |
4022 \item \code{im.memberName} evaluates to \code{'m'}. | 4065 \item \code{im.memberName} evaluates to \code{'m'}. |
4023 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . | 4066 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . |
4024 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 4067 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
4025 \end{itemize} | 4068 \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 : | 4069 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} | 4070 \begin{itemize} |
4028 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 4071 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. |
4029 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 4072 \item \code{im'.memberName} evaluates to \code{noSuchMethod}. |
4030 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 4073 \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{} \{\}}. | 4074 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
4032 \end{itemize} | 4075 \end{itemize} |
4033 | |
4034 and the result of this latter invocation is the result of evaluating $i$. | 4076 and the result of this latter invocation is the result of evaluating $i$. |
4035 | 4077 |
4036 \LMHash{} | 4078 \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}. | 4079 It is a static type warning if $S$ does not have an accessible instance method o r getter named $m$. |
4080 | |
4081 The static type of $i$ is: | |
4082 \begin{itemize} | |
4083 \item The declared return type of $S.m$, if $S$ has an accessible instance gette r named $m$. | |
4084 \item The static type of function $S.m$ if $S$ has an accessible instance method named $m$. | |
4085 \item The type \DYNAMIC{} otherwise. | |
4086 \end{itemize} | |
4038 | 4087 |
4039 | 4088 |
4040 \subsubsection{Closurization} | 4089 \subsubsection{General Closurization} |
4041 \LMLabel{closurization} | 4090 \LMLabel{generalClosurization} |
4042 | 4091 |
4043 \LMHash{} | 4092 \LMHash{} |
4044 The {\em closurization of $o.m$} is defined to be equivalent to: | 4093 Evaluation of a property extraction $i$ of the form $e\#m$ proceeds as follows: |
4045 | 4094 |
4095 \LMHash{} | |
4096 First, the expression $e$ is evaluated to an object $o$. Let $f$ be the result o f 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 to a static method, method lookup fails. If method lo okup succeeds then $i$ evaluates to the closurization of method $f$ on object $o $ (\ref{ordinaryMemberClosurization}). | |
4097 | |
4098 \LMHash{} | |
4099 Otherwise, let $f$ be the result of looking up getter $m$ in $o$ with respect t o 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 closu rization of getter $f$ on object $o$ (\ref{ordinaryMemberClosurization}). | |
4100 | |
4101 \LMHash{} | |
4102 Otherwise, let $f$ be the result of looking up setter $m$ in $o$ with respect t o 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 setter , setter lookup fails. If setter lookup succeeds then $i$ evaluates to the closu rization of setter $f$ on object $o$ (\ref{ordinaryMemberClosurization}). | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
So we technically go through the previous two look
sra1
2015/03/26 19:41:38
It seems that this would be simpler if the closuri
gbracha
2015/03/26 23:21:22
Yes, I think splitting it makes a lot of sense, fo
| |
4103 | |
4104 | |
4105 \LMHash{} | |
4106 Otherwise, a new instance $im$ of the predefined class \code{Invocation} is created, such that : | |
4046 \begin{itemize} | 4107 \begin{itemize} |
4108 \item If $m$ is a setter name, \code{im.isSetter} evaluates to \code{\TRUE{}}; otherwise \code{im.isMethod} evaluates to \code{\TRUE{}} | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
I still think this is dangerously wrong, and must
sra1
2015/03/26 19:41:38
I think this would also be fixed by e#foo / e#get
Lasse Reichstein Nielsen
2015/03/26 20:23:23
I don't see how that would change anything. There
gbracha
2015/03/26 23:21:22
Good point. Indeed, existing tear-offs using the e
Lasse Reichstein Nielsen
2015/03/27 07:03:04
The existing extraction works because of the corre
| |
4109 \item \code{im.memberName} evaluates to \code{'m'}. | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
This looks like it evaluates to a string, but it s
gbracha
2015/03/26 23:21:22
A bug that has been lying dormant for a while. Fix
| |
4110 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Are we requiring "const []" in other places too? O
eernst
2015/03/26 22:38:50
Why not \code{\CONST{} <Object>[]}, such that List
gbracha
2015/03/26 23:21:22
We have been doing this in similar situations with
| |
4111 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
4112 \end{itemize} | |
4113 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 : | |
4114 \begin{itemize} | |
4115 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. | |
4116 \item \code{im'.memberName} evaluates to \code{noSuchMethod}. | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Symbol #noSuchMethod ?
gbracha
2015/03/26 23:21:22
Done everywhere in response to previous comment.
| |
4117 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. | |
4118 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
eernst
2015/03/26 22:38:50
Could again be <Object>[$im$] and \CONST <Object>\
| |
4119 \end{itemize} | |
4120 and the result of this latter invocation is the result of evaluating $i$. | |
4047 | 4121 |
4122 \LMHash{} | |
4123 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}. | |
4124 | |
4125 \commentary{ | |
4126 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. | |
4127 } | |
4128 | |
4129 \LMHash{} | |
4130 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: | |
Paul Berry
2015/03/26 18:55:58
It seems inconsistent that on line 4102 we allow e
| |
4131 \begin{itemize} | |
4132 \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 | |
Paul Berry
2015/03/26 18:55:58
Nit: when this text appears elsewhere in the spec,
| |
4133 \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$. | |
Paul Berry
2015/03/26 18:55:58
Similarly, "or setter" should be added here.
| |
4134 \end{itemize} | |
4135 | |
4136 The static type of $i$ is: | |
4137 \begin{itemize} | |
4138 \item The static type of function $T.m$, if $T$ has an accessible instance membe r named $m$. | |
4139 \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$. | |
4140 \item The type \DYNAMIC{} otherwise. | |
4141 \end{itemize} | |
Paul Berry
2015/03/26 18:55:58
Consider adding some non-normative explanatory tex
| |
4142 | |
4143 \subsubsection{Named Constructor Extraction} | |
4144 \LMLabel{namedConstructorExtraction} | |
4145 | |
4146 \LMHash{} | |
4147 Evaluation of a property extraction $i$ of the form \NEW{} $T\#m$ or \CONST{} $T \#m$ proceeds as follows: | |
Paul Berry
2015/03/26 18:55:58
This is inconsistent with line 2352, where the con
| |
4148 | |
4149 \LMHash{} | |
4150 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}). | |
4151 | |
4152 \commentary{Note that if $T$ is malformed or malbounded, a static warning occurs , as always.} | |
4153 | |
4154 \LMHash{} | |
4155 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{}. | |
Paul Berry
2015/03/26 18:55:58
"$f$" can be removed, since nothing refers to it.
| |
4156 | |
4157 \subsubsection{Anonymous Constructor Extraction} | |
4158 \LMLabel{anonymousConstructorExtraction} | |
4159 | |
4160 \LMHash{} | |
4161 Evaluation of a property extraction $i$ of the form \NEW{} $T\#$ or \CONST{} $T\ #$ proceeds as follows: | |
4162 | |
4163 \LMHash{} | |
4164 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}). | |
4165 | |
4166 \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.} | |
Paul Berry
2015/03/26 18:55:58
I think you mean "This also means that \NEW{} $x\#
| |
4167 | |
4168 \LMHash{} | |
4169 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{}. | |
4170 | |
4171 \subsubsection{General Super Property Extraction} | |
4172 \LMLabel{generalSuperPropertyExtraction} | |
4173 | |
4174 | |
4175 \LMHash{} | |
4176 Evaluation of a property extraction $i$ of the form \SUPER$\#m$ proceeds as foll ows: | |
4177 | |
4178 Let $S$ be the superclass of the immediately enclosing class. Let $f$ be the res ult of looking up method $m$ in $S$ with respect to the current library $L$. If method lookup succeeds then $i$ evaluates to the closurization of method $m$ wit h respect to superclass $S$ (\ref{superClosurization}). | |
4179 | |
4180 \LMHash{} | |
4181 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}). | |
4182 | |
4183 \LMHash{} | |
4184 Otherwise, let $f$ be the result of looking up setter $m$ in $S$ with respect t o the current library $L$. If setter lookup succeeds then $i$ evaluates to the c losurization of setter $f$ with respect to superclass $S$ (\ref{superClosuriza tion}). | |
4185 | |
4186 | |
4187 \LMHash{} | |
4188 Otherwise, a new instance $im$ of the predefined class \code{Invocation} is created, such that : | |
4189 \begin{itemize} | |
4190 \item If $m$ is a setter name, \code{im.isSetter} evaluates to \code{\TRUE{}}; otherwise \code{im.isMethod} evaluates to \code{\TRUE{}} | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Same comment as above: Just throw a NoSuchMethodEr
gbracha
2015/03/26 23:21:21
Done.
| |
4191 \item \code{im.memberName} evaluates to \code{'m'}. | |
4192 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . | |
4193 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
eernst
2015/03/26 22:38:50
Again we could have <Object>[] and <Object>{}.
| |
4194 \end{itemize} | |
4195 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 : | |
4196 \begin{itemize} | |
4197 \item \code{$im'$.isMethod} evaluates to \code{\TRUE{}}. | |
4198 \item \code{$im'$.memberName} evaluates to \code{noSuchMethod}. | |
4199 \item \code{$im'$.positionalArguments} evaluates to an immutable list whose sole element is $im$. | |
4200 \item \code{$im'$.namedArguments} evaluates to the value of \code{\CONST{} \{\}} . | |
eernst
2015/03/26 22:38:51
<Object>{}.
| |
4201 \end{itemize} | |
4202 and the result of this latter invocation is the result of evaluating $i$. | |
4203 | |
4204 \LMHash{} | |
4205 It is a static type warning if $S$ does not have an accessible instance member n amed $m$. | |
4206 | |
4207 \LMHash{} | |
4208 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{}. | |
4209 | |
4210 | |
4211 | |
4212 \subsubsection{Ordinary Member Closurization} | |
4213 \LMLabel{ordinaryMemberClosurization} | |
4214 | |
4215 | |
4216 \LMHash{} | |
4217 Let $o$ be an object, and let $u$ be a fresh final variable bound to $o$. | |
4218 The {\em closurization of method $f$ on object $o$} is defined to be equivalent to: | |
4219 \begin{itemize} | |
4220 \item $(a) \{\RETURN{}$ $u$ $m$ $a;$\} if $f$ is named $m$ and $m$ is one of \c ode{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<<$, $>>$} (this precludes closurization of unary -). | |
4221 \item $() \{\RETURN{}$ \~{} $u;$\} if $f$ is named \~{}. | |
4222 \item $(a) \{\RETURN{}$ $u[a];$\} if $f$ is named $[]$. | |
4223 \item $(a, b) \{\RETURN{}$ $u[a] = b;$\} if $f$ is named $[]=$. | |
4048 \item | 4224 \item |
4049 \begin{dartCode} | 4225 \begin{dartCode} |
4050 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ | 4226 $(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);$ | 4227 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ |
4052 \} | 4228 \} |
4053 \end{dartCode} | 4229 \end{dartCode} |
4054 | 4230 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 | 4231 \item |
4057 \begin{dartCode} | 4232 \begin{dartCode} |
4058 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | 4233 $(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)$; | 4234 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; |
4060 \} | 4235 \} |
4061 \end{dartCode} | 4236 \end{dartCode} |
4062 | 4237 |
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$. | 4238 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} | 4239 \end{itemize} |
4065 | 4240 |
4066 where $u$ is a fresh final variable bound to $o$, except that: | 4241 \LMHash{} |
4067 \begin{enumerate} | 4242 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$}. | 4243 %\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{}. |
eernst
2015/03/26 22:38:51
Why is this commented out?
| |
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{}. | 4244 |
4070 \end{enumerate} | 4245 \LMHash{} |
4246 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$}. | |
4247 | |
4248 \LMHash{} | |
4249 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 | 4250 |
4072 \commentary{ | 4251 \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. | 4252 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 } | 4253 } |
4075 % local functions that have a closure extracted are always different | 4254 % local functions that have a closure extracted are always different |
4076 | 4255 |
4077 \rationale{ | 4256 \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. | 4257 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 } | 4258 } |
4080 | 4259 |
4260 \commentary { | |
4261 Observations: | |
4262 | |
4263 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. | |
4264 } | |
4265 | |
4081 | 4266 |
4082 | 4267 |
4268 \subsubsection{Named Constructor Closurization} | |
4269 \LMLabel{namedConstructorClosurization} | |
4083 | 4270 |
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{} | 4271 \LMHash{} |
4094 The closurization of $\SUPER{}.m$ with respect to superclass $S$ is defined to b e equivalent to: | 4272 The {\em closurization of constructor $f$ of type $T$} is defined to be equivale nt to: |
4095 | |
4096 \begin{itemize} | 4273 \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 | 4274 \item |
4101 \begin{dartCode} | 4275 \begin{dartCode} |
4102 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$\{ | 4276 $(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)$; | 4277 \RETURN{} \NEW{} $T.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ |
4278 \} | |
4279 \end{dartCode} | |
4280 | |
4281 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$. | |
4282 \item | |
4283 \begin{dartCode} | |
4284 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | |
4285 \RETURN{} \NEW{} $T.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | |
4104 \} | 4286 \} |
4105 \end{dartCode} | 4287 \end{dartCode} |
4106 | 4288 |
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$. | 4289 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$. |
4290 \end{itemize} | |
4291 | |
4292 \LMHash{} | |
4293 Except that iff \code{identical($T_1, T_2$)} then \cd{\NEW{} $T_1\#m$ == \NEW {} $T_2\#m$}. | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
The identical(T_1, T_2) looks odd when you are com
gbracha
2015/03/26 23:21:21
Then I have to exclude parameterized types somehow
| |
4294 | |
4295 \commentary{ | |
4296 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. | |
4297 } | |
4298 | |
4299 \subsubsection{Anonymous Constructor Closurization} | |
4300 \LMLabel{anonymousConstructorClosurization} | |
4301 | |
4302 \LMHash{} | |
4303 The {\em closurization of anonymous constructor $f$ of type $T$} is defined to b e equivalent to: | |
4304 \begin{itemize} | |
4305 \item | |
4306 \begin{dartCode} | |
4307 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ | |
4308 \RETURN{} \NEW{} $T(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | |
4309 \} | |
4310 \end{dartCode} | |
4311 | |
4312 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 | 4313 \item |
4109 \begin{dartCode} | 4314 \begin{dartCode} |
4110 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | 4315 $(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)$; | 4316 \RETURN{} \NEW{} $T(r_1, \ldots, r_n, p_1, \ldots, p_k)$; |
4112 \} | 4317 \} |
4113 \end{dartCode} | 4318 \end{dartCode} |
4114 | 4319 |
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$. | 4320 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} | 4321 \end{itemize} |
4117 | 4322 |
4118 \LMHash{} | 4323 \LMHash{} |
4119 Except that: | 4324 Except that iff \code{identical($T_1, T_2$)} then \cd{\NEW{} $T_1\#$ == \NEW{ } $T_2\#$}. |
4120 \begin{enumerate} | 4325 |
4121 \item iff \code{identical($o_1, o_2$)} then \cd{$o_1.m$ == $o_2.m$}. | 4326 |
4327 \subsubsection{Super Closurization} | |
4328 \LMLabel{superClosurization} | |
4329 | |
4330 \LMHash{} | |
4331 The {\em closurization of method $f$ with respect to superclass $S$} is defined to be equivalent to: | |
4332 | |
4333 \LMHash{} | |
4334 \begin{itemize} | |
4335 \item $(a) \{\RETURN{}$ \SUPER{} $m$ $a;$\} if $f$ is named $m$ and $m$ is one o f \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<<$, $>>$}. | |
4336 \item $() \{\RETURN{}$ \~{}\SUPER;\} if $f$ is named \~{}. | |
4337 \item $(a) \{\RETURN{}$ $\SUPER[a];$\} if $f$ is named $[]$. | |
4338 \item $(a, b) \{\RETURN{}$ $\SUPER[a] = b;$\} if $f$ is named $[]=$. | |
4339 \item | |
4340 \begin{dartCode} | |
4341 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ | |
4342 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | |
4343 \} | |
4344 \end{dartCode} | |
4345 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 | 4346 \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{} . | 4347 \begin{dartCode} |
4124 \end{enumerate} | 4348 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ |
4349 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | |
4350 \} | |
4351 \end{dartCode} | |
4352 | |
4353 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$. | |
4354 \end{itemize} | |
4355 | |
4356 \LMHash{} | |
4357 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$}. | |
4358 | |
4359 | |
4360 \LMHash{} | |
4361 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$}. | |
4362 | |
4363 \LMHash{} | |
4364 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=$}. | |
4365 | |
4125 | 4366 |
4126 | 4367 |
4127 \subsection{ Assignment} | 4368 \subsection{ Assignment} |
4128 \LMLabel{assignment} | 4369 \LMLabel{assignment} |
4129 | 4370 |
4130 \LMHash{} | 4371 \LMHash{} |
4131 An assignment changes the value associated with a mutable variable or property. | 4372 An assignment changes the value associated with a mutable variable or property. |
4132 | 4373 |
4133 \begin{grammar} | 4374 \begin{grammar} |
4134 {\bf assignmentOperator:}`=' ; | 4375 {\bf assignmentOperator:}`=' ; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4167 \LMHash{} | 4408 \LMHash{} |
4168 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. | 4409 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. |
4169 | 4410 |
4170 \LMHash{} | 4411 \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$. | 4412 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 | 4413 |
4173 \LMHash{} | 4414 \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$. | 4415 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 | 4416 |
4176 \LMHash{} | 4417 \LMHash{} |
4418 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$. | |
eernst
2015/03/26 22:38:50
It might be an error-prone choice to let $e_2$ be
Lasse Reichstein Nielsen
2015/03/27 07:14:45
The ?? operator is definitely short-circuit: (e1 ?
eernst
2015/03/27 08:44:03
For (e1 || e2), the rationale for the short-circui
Lasse Reichstein Nielsen
2015/03/27 15:42:09
We don't actually have "v ?= e", only "o?.p = e" w
eernst
2015/04/07 10:44:49
Sorry, I meant "v ??= e".
I think the most intuit
| |
4419 | |
4420 \LMHash{} | |
4177 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws: | 4421 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws: |
4178 | 4422 |
4179 \LMHash{} | 4423 \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$. | 4424 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 | 4425 |
4182 \LMHash{} | 4426 \LMHash{} |
4183 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 4427 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} | 4428 \begin{itemize} |
4185 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. | 4429 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. |
4186 \item \code{im.memberName} evaluates to \code{'v='}. | 4430 \item \code{im.memberName} evaluates to \code{'v='}. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4226 | 4470 |
4227 \LMHash{} | 4471 \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 `.'. | 4472 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 | 4473 |
4230 | 4474 |
4231 | 4475 |
4232 \subsubsection{Compound Assignment} | 4476 \subsubsection{Compound Assignment} |
4233 \LMLabel{compoundAssignment} | 4477 \LMLabel{compoundAssignment} |
4234 | 4478 |
4235 \LMHash{} | 4479 \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 | 4480 Evaluation of a compound assignment of the form $v$ $\code{??=} e$ is equivalent to the evaluation of the expression $((x) => x == \NULL? v=e : x)(v)$ where $ x$ is a variable that is not used in $e$. Evaluation of a compound assignment of the form $C.v$ $\code{??=} e$, where $C$ is a type literal, is equivalent to th e evaluation of the expression $((x) => x == \NULL? C.v=e: x)(C.v)$ where $x$ is a variable that is not used in $e$. Evaluation of a compound assignment of th e form $e_1.v$ $\code{??=} e_2$ is equivalent to the evaluation of the expressi on $((x) =>((y) => y == \NULL? x.v = e_2: y)(x.v))(e_1)$ where $x$ and $y$ are distinct variables that are not used in $e_2$. Evaluation of a compound assignm ent of the form $e_1[e_2]$ $\code{??=} e_3$ is equivalent to the evaluation of the expression |
Paul Berry
2015/03/26 15:07:21
Nit: the pdf output of this paragraph contains som
eernst
2015/03/26 22:38:50
If null-awareness should not change the number of
eernst
2015/03/26 22:38:50
Typo?: $((x) ..)(..)$ vs. \code{((x) $=>$ ..)(..)}
gbracha
2015/03/26 23:21:22
Yes, I am aware of that. I made some changes, but
| |
4481 $((a, i) => ((x) => x == \NULL? a[i] = e_3: x)(a[i]))(e_1, e_2)$ where $x$, $a$ and $i$ are distinct variables that are not used in $e_3$. Evaluation of a comp ound assignment of the form $e_1?.v$ $\code{??=} e_2$ is equivalent to the eval uation of the expression \code{((x) $=>$ x == \NULL? \NULL: $x.v ??= e_2$)($e_1 $)} where $x$ is a variable that is not used in $e_2$. | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Need to address super.x ??= y too?
eernst
2015/03/26 22:38:50
How about \code{$e_1$ == null}?
gbracha
2015/03/26 23:21:21
Hmm. Actually, I think we don't really cover super
gbracha
2015/03/26 23:21:22
Done.
gbracha
2015/03/26 23:21:22
How about it :-) ? Sorry not clear what you mean.
eernst
2015/03/27 08:44:03
Actually, thinking about it, no special checking i
| |
4482 | |
4483 | |
4484 \LMHash{} | |
4485 The static type of a compound assignment of the form $v$ $\code{??=} e$ or the f orm $C.v$ $\code{??=} e$ is the static type of $e$. The static type of a compoun d assignment of the form $e_1.v$ $\code{??=} e_2$ is the static type of $e_2$. The static type of a compound assignment of the form $e_1[e_2]$ $\code{??=} e_3 $ is the static type of $e_3$. | |
Paul Berry
2015/03/26 15:07:21
I don't think this is what we want. Consider the
gbracha
2015/03/26 23:21:22
Right. Likewise for all variants (v , C.v, e1.v, e
| |
4486 | |
4487 \LMHash{} | |
4488 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$. | 4489 \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 | 4490 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 i n $e_2$. |
Paul Berry
2015/03/26 15:07:21
Nit: there are some spacing errors in this paragra
| |
4239 | 4491 |
4240 \begin{grammar} | 4492 \begin{grammar} |
4241 {\bf compoundAssignmentOperator:}`*='; | 4493 {\bf compoundAssignmentOperator:}`*='; |
4242 `/='; | 4494 `/='; |
4243 `\~{}/='; | 4495 `\~{}/='; |
4244 `\%='; | 4496 `\%='; |
4245 `+='; | 4497 `+='; |
4246 `-='; | 4498 `-='; |
4247 `{\escapegrammar \lt \lt}='; | 4499 `{\escapegrammar \lt \lt}='; |
4248 `{\escapegrammar \gt \gt}='; | 4500 `{\escapegrammar \gt \gt}='; |
4249 `\&='; | 4501 `\&='; |
4250 `\^{}='; | 4502 `\^{}='; |
4251 `$|$=' | 4503 `$|$='; |
4504 `??='; | |
4252 . | 4505 . |
4253 \end{grammar} | 4506 \end{grammar} |
4254 | 4507 |
4255 | 4508 |
4256 \subsection{ Conditional} | 4509 \subsection{ Conditional} |
4257 \LMLabel{conditional} | 4510 \LMLabel{conditional} |
4258 | 4511 |
4259 \LMHash{} | 4512 \LMHash{} |
4260 A {\em conditional expression} evaluates one of two expressions based on a boole an condition. | 4513 A {\em conditional expression} evaluates one of two expressions based on a boole an condition. |
4261 | 4514 |
4262 \begin{grammar} | 4515 \begin{grammar} |
4263 {\bf conditionalExpression:} | 4516 {\bf conditionalExpression:} |
4264 logicalOrExpression (`?' expressionWithoutCascade `{\escapegrammar :}' expr essionWithoutCascade)? | 4517 ifNullExpression (`?' expressionWithoutCascade `{\escapegrammar :}' express ionWithoutCascade)? |
4265 . % the first branches could top level expressions, it seems, but certainl y NOT the second | 4518 . % the first branches could top level expressions, it seems, but certainl y NOT the second |
4266 \end{grammar} | 4519 \end{grammar} |
4267 | 4520 |
4268 \LMHash{} | 4521 \LMHash{} |
4269 Evaluation of a conditional expression $c$ of the form $e_1 ? e_2 : e_3$ proceed s as follows: | 4522 Evaluation of a conditional expression $c$ of the form $e_1 ? e_2 : e_3$ proceed s as follows: |
4270 | 4523 |
4271 \LMHash{} | 4524 \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$. | 4525 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 | 4526 |
4274 \LMHash{} | 4527 \LMHash{} |
4275 If all of the following hold: | 4528 If all of the following hold: |
4276 \begin{itemize} | 4529 \begin{itemize} |
4277 \item $e_1$ shows that a variable $v$ has type $T$. | 4530 \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. | 4531 \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$. | 4532 \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} | 4533 \end{itemize} |
4281 | 4534 |
4282 then the type of $v$ is known to be $T$ in $e_2$. | 4535 then the type of $v$ is known to be $T$ in $e_2$. |
4283 | 4536 |
4284 | 4537 |
4285 \LMHash{} | 4538 \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$. | 4539 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$. |
4540 | |
4541 | |
4542 \subsection{If-null Expressions} | |
4543 \label{ifNull} | |
4544 | |
4545 \LMHash{} | |
4546 An {\em if-null expression}evaluates an expression and if the result is \NULL, evaluates another. | |
4547 | |
4548 \begin{grammar} | |
4549 {\bf ifNullExpression:} | |
4550 logicalOrExpression (`??' logicalOrExpression)* | |
4551 \end{grammar} | |
4552 | |
4553 \LMHash{} | |
4554 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 | 4555 |
4288 | 4556 |
4289 \subsection{ Logical Boolean Expressions} | 4557 \subsection{ Logical Boolean Expressions} |
4290 \LMLabel{logicalBooleanExpressions} | 4558 \LMLabel{logicalBooleanExpressions} |
4291 | 4559 |
4292 \LMHash{} | 4560 \LMHash{} |
4293 The logical boolean expressions combine boolean objects using the boolean conjun ction and disjunction operators. | 4561 The logical boolean expressions combine boolean objects using the boolean conjun ction and disjunction operators. |
4294 | 4562 |
4295 \begin{grammar} | 4563 \begin{grammar} |
4296 {\bf logicalOrExpression:} | 4564 {\bf logicalOrExpression:} |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4626 | 4894 |
4627 | 4895 |
4628 \subsection{ Postfix Expressions} | 4896 \subsection{ Postfix Expressions} |
4629 \LMLabel{postfixExpressions} | 4897 \LMLabel{postfixExpressions} |
4630 | 4898 |
4631 \LMHash{} | 4899 \LMHash{} |
4632 Postfix expressions invoke the postfix operators on objects. | 4900 Postfix expressions invoke the postfix operators on objects. |
4633 | 4901 |
4634 \begin{grammar} | 4902 \begin{grammar} |
4635 {\bf postfixExpression:}assignableExpression postfixOperator; | 4903 {\bf postfixExpression:}assignableExpression postfixOperator; |
4636 primary selector* | 4904 primary (selector* $|$ ( `\#' ( (identifier `='?) $|$ operator))) |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Could the #-syntax be part of selector instead?
I
gbracha
2015/03/26 23:21:21
I'm not inclined to outlaw the abuse.
| |
4637 . | 4905 . |
4638 | 4906 |
4639 {\bf postfixOperator:} | 4907 {\bf postfixOperator:} |
4640 incrementOperator | 4908 incrementOperator |
4641 . | 4909 . |
4642 | 4910 |
4643 {\bf selector:}assignableSelector; | 4911 {\bf selector:}assignableSelector; |
4644 arguments | 4912 arguments |
4645 . | 4913 . |
4646 | 4914 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4709 | 4977 |
4710 | 4978 |
4711 \begin{grammar} | 4979 \begin{grammar} |
4712 | 4980 |
4713 {\bf assignableExpression:}primary (arguments* assignableSelector)+; | 4981 {\bf assignableExpression:}primary (arguments* assignableSelector)+; |
4714 \SUPER{} assignableSelector; | 4982 \SUPER{} assignableSelector; |
4715 identifier | 4983 identifier |
4716 . | 4984 . |
4717 | 4985 |
4718 {\bf assignableSelector:}`[' expression `]'; % again, could be top level | 4986 {\bf assignableSelector:}`[' expression `]'; % again, could be top level |
4719 `{\escapegrammar .}' identifier | 4987 `{\escapegrammar .}' identifier; |
4988 `{\escapegrammar ?.}' identifier | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Different indentation?
gbracha
2015/03/26 23:21:22
Acknowledged.
| |
4720 . | 4989 . |
4721 | 4990 |
4722 \end{grammar} | 4991 \end{grammar} |
4723 | 4992 |
4724 \LMHash{} | 4993 \LMHash{} |
4725 An {\em assignable expression} is either: | 4994 An assignable expression can be {\em conditional} or {\em unconditional}. |
4995 | |
4996 Evaluation of a {\em conditional assignable expression} $e$ of the form $e_1?.id $ is equivalent to the evaluation of the expression $((x) => x == \NULL ? \NUL L : x.id)(e_1)$. The static type of $e$ is the same as the static type of $e_1.i d$. | |
4997 | |
4998 \commentary{ | |
4999 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$, the $e.v$ refers to that member, but $e?.v$ does not. | |
5000 } | |
5001 | |
5002 \rationale{ | |
5003 One could try and address this with special case rules, but this is simply a mat ter of digging oneself deeper into a hole. Removing the restrictions on the use of types as objects is the proper way to resolve this issue. | |
Lasse Reichstein Nielsen
2015/03/26 10:38:48
Objection, editorializing!
gbracha
2015/03/26 23:21:22
I am the editor, after all. I wondered if anyone w
| |
5004 } | |
5005 | |
5006 | |
5007 \LMHash{} | |
5008 An {\em unconditional assignable expression} is either: | |
4726 \begin{itemize} | 5009 \begin{itemize} |
4727 \item An identifier. | 5010 \item An identifier. |
4728 \item An invocation of a getter (\ref{getters}) or list access operator on an ex pression $e$. | 5011 \item An invocation of a getter (\ref{getters}) or list access operator on an ex pression $e$. |
4729 \item An invocation of a getter or list access operator on \SUPER{}. | 5012 \item An invocation of a getter or list access operator on \SUPER{}. |
4730 \end{itemize} | 5013 \end{itemize} |
4731 | 5014 |
4732 | 5015 |
4733 \LMHash{} | 5016 \LMHash{} |
4734 An assignable expression of the form $id$ is evaluated as an identifier expressi on (\ref{identifierReference}). | 5017 An assignable expression of the form $id$ is evaluated as an identifier expressi on (\ref{identifierReference}). |
4735 | 5018 |
(...skipping 924 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: | 5943 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 | 5944 |
5662 \LMHash{} | 5945 \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. | 5946 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 | 5947 |
5665 | 5948 |
5666 \LMHash{} | 5949 \LMHash{} |
5667 A finally clause \FINALLY{} $s$ defines an exception handler $h$ that executes a s follows: | 5950 A finally clause \FINALLY{} $s$ defines an exception handler $h$ that executes a s follows: |
5668 | 5951 |
5669 \LMHash{} | 5952 \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. | 5953 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 | 5954 |
5672 \rationale{ | 5955 \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. | 5956 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 } | 5957 } |
5675 | 5958 |
5676 \LMHash{} | 5959 \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: | 5960 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} | 5961 \begin{itemize} |
5679 \item | 5962 \item |
5680 if there is a dynamically enclosing error handler $g$ defined by a \FINALLY{} c lause in $m$, control is transferred to $g$. | 5963 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} | 6149 \begin{grammar} |
5867 {\bf breakStatement:} | 6150 {\bf breakStatement:} |
5868 \BREAK{} identifier? `{\escapegrammar ;}' | 6151 \BREAK{} identifier? `{\escapegrammar ;}' |
5869 . | 6152 . |
5870 \end{grammar} | 6153 \end{grammar} |
5871 | 6154 |
5872 \LMHash{} | 6155 \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$. | 6156 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 | 6157 |
5875 \LMHash{} | 6158 \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$. | 6159 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 | 6160 |
5878 | 6161 |
5879 | 6162 |
5880 \subsection{ Continue} | 6163 \subsection{ Continue} |
5881 \LMLabel{continue} | 6164 \LMLabel{continue} |
5882 | 6165 |
5883 \LMHash{} | 6166 \LMHash{} |
5884 The {\em continue statement} consists of the reserved word \CONTINUE{} and an op tional label (\ref{labels}). | 6167 The {\em continue statement} consists of the reserved word \CONTINUE{} and an op tional label (\ref{labels}). |
5885 | 6168 |
5886 \begin{grammar} | 6169 \begin{grammar} |
5887 {\bf continueStatement:} | 6170 {\bf continueStatement:} |
5888 \CONTINUE{} identifier? `{\escapegrammar ;}' | 6171 \CONTINUE{} identifier? `{\escapegrammar ;}' |
5889 . | 6172 . |
5890 \end{grammar} | 6173 \end{grammar} |
5891 | 6174 |
5892 \LMHash{} | 6175 \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. | 6176 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 | 6177 |
5895 \commentary{ | 6178 \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. | 6179 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 } | 6180 } |
5898 | 6181 |
5899 \LMHash{} | 6182 \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$. | 6183 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 | 6184 |
5902 \subsection{ Yield and Yield-Each} | 6185 \subsection{ Yield and Yield-Each} |
5903 \LMLabel{yieldAndYieldEach} | 6186 \LMLabel{yieldAndYieldEach} |
5904 | 6187 |
5905 \subsubsection{ Yield} | 6188 \subsubsection{ Yield} |
5906 \LMLabel{yield} | 6189 \LMLabel{yield} |
5907 | 6190 |
5908 \LMHash{} | 6191 \LMHash{} |
5909 The {\em yield statement} adds an element to the result of a generator function (\ref{functions}). | 6192 The {\em yield statement} adds an element to the result of a generator function (\ref{functions}). |
5910 | 6193 |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7215 \LMHash{} | 7498 \LMHash{} |
7216 Operator precedence is given implicitly by the grammar. | 7499 Operator precedence is given implicitly by the grammar. |
7217 | 7500 |
7218 \commentary{The following non-normative table may be helpful | 7501 \commentary{The following non-normative table may be helpful |
7219 \newline | 7502 \newline |
7220 | 7503 |
7221 \begin{tabular}{| r | r | r | r |} | 7504 \begin{tabular}{| r | r | r | r |} |
7222 \hline | 7505 \hline |
7223 Description & Operator & Associativity & Precedence \\ | 7506 Description & Operator & Associativity & Precedence \\ |
7224 \hline | 7507 \hline |
7225 Unary postfix & ., e++, e--, e1[e2], e1() , () & None & 15 \\ | 7508 Unary postfix & ., e++, e--, e1[e2], e1() , () & None & 15 \\ |
Paul Berry
2015/03/26 15:07:21
Add "?." to the table.
gbracha
2015/03/26 23:21:22
Done.
| |
7226 \hline | 7509 \hline |
7227 Unary prefix & -e, !e, \~{}e, ++e, --e & None & 14\\ | 7510 Unary prefix & -e, !e, \~{}e, ++e, --e & None & 14\\ |
7228 \hline | 7511 \hline |
7229 Multiplicative & *, /, \~/, \% & Left & 13\\ | 7512 Multiplicative & *, /, \~/, \% & Left & 13\\ |
7230 \hline | 7513 \hline |
7231 Additive & +, - & Left & 12\\ | 7514 Additive & +, - & Left & 12\\ |
7232 \hline | 7515 \hline |
7233 Shift & $<<$, $>>$& Left & 11\\ | 7516 Shift & $<<$, $>>$& Left & 11\\ |
7234 \hline | 7517 \hline |
7235 Bitwise AND & \& & Left & 10\\ | 7518 Bitwise AND & \& & Left & 10\\ |
7236 \hline | 7519 \hline |
7237 Bitwise XOR & \^{} & Left & 9\\ | 7520 Bitwise XOR & \^{} & Left & 9\\ |
7238 \hline | 7521 \hline |
7239 Bitwise Or & $|$ & Left & 8\\ | 7522 Bitwise Or & $|$ & Left & 8\\ |
7240 \hline | 7523 \hline |
7241 Relational & $<$, $>$, $<=$, $>=$, \AS{}, \IS{}, \IS{}! & None & 7\\ | 7524 Relational & $<$, $>$, $<=$, $>=$, \AS{}, \IS{}, \IS{}! & None & 7\\ |
7242 \hline | 7525 \hline |
7243 Equality & ==, != & None & 6\\ | 7526 Equality & ==, != & None & 6\\ |
7244 \hline | 7527 \hline |
7245 Logical AND & \&\& & Left & 5\\ | 7528 Logical AND & \&\& & Left & 5\\ |
7246 \hline | 7529 \hline |
7247 Logical Or & $||$ & Left & 4\\ | 7530 Logical Or & $||$ & Left & 4\\ |
7248 \hline | 7531 \hline |
Paul Berry
2015/03/26 15:07:21
Add "??" to the table (left-associative).
gbracha
2015/03/26 23:21:21
Done.
| |
7249 Conditional & e1? e2: e3 & Right & 3\\ | 7532 Conditional & e1? e2: e3 & Right & 3\\ |
7250 \hline | 7533 \hline |
7251 Cascade & .. & Left & 2\\ | 7534 Cascade & .. & Left & 2\\ |
7252 \hline | 7535 \hline |
7253 Assignment & =, *=, /=, +=, -= ,\&=, \^{}= etc. & Right & 1\\ | 7536 Assignment & =, *=, /=, +=, -= ,\&=, \^{}= etc. & Right & 1\\ |
7254 \hline | 7537 \hline |
7255 \end{tabular} | 7538 \end{tabular} |
7256 } | 7539 } |
7257 %\subsection{Glossary} | 7540 %\subsection{Glossary} |
7258 %\LMLabel{glossary} | 7541 %\LMLabel{glossary} |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7421 | 7704 |
7422 The invariant that each normative paragraph is associated with a line | 7705 The invariant that each normative paragraph is associated with a line |
7423 containing the text \LMHash{} should be maintained. Extra occurrences | 7706 containing the text \LMHash{} should be maintained. Extra occurrences |
7424 of \LMHash{} can be added if needed, e.g., in order to make | 7707 of \LMHash{} can be added if needed, e.g., in order to make |
7425 individual \item{}s in itemized lists addressable. Each \LM.. command | 7708 individual \item{}s in itemized lists addressable. Each \LM.. command |
7426 must occur on a separate line. \LMHash{} must occur immediately | 7709 must occur on a separate line. \LMHash{} must occur immediately |
7427 before the associated paragraph, and \LMLabel must occur immediately | 7710 before the associated paragraph, and \LMLabel must occur immediately |
7428 after the associated \section{}, \subsection{} etc. | 7711 after the associated \section{}, \subsection{} etc. |
7429 | 7712 |
7430 ---------------------------------------------------------------------- | 7713 ---------------------------------------------------------------------- |
OLD | NEW |