OLD | NEW |
---|---|
1 \documentclass{article} | 1 \documentclass{article} |
2 \usepackage{epsfig} | 2 \usepackage{epsfig} |
3 \usepackage{color} | 3 \usepackage{color} |
4 \usepackage{dart} | 4 \usepackage{dart} |
5 \usepackage{bnf} | 5 \usepackage{bnf} |
6 \usepackage{hyperref} | 6 \usepackage{hyperref} |
7 \usepackage{lmodern} | 7 \usepackage{lmodern} |
8 \newcommand{\code}[1]{{\sf #1}} | 8 \newcommand{\code}[1]{{\sf #1}} |
9 \title{Dart Programming Language Specification \\ | 9 \title{Dart Programming Language Specification \\ |
10 {4th edition draft}\\ | 10 {4th edition draft}\\ |
(...skipping 20 matching lines...) Expand all Loading... | |
31 \LMHash{} | 31 \LMHash{} |
32 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 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}). |
33 | 33 |
34 \section{Conformance} | 34 \section{Conformance} |
35 \LMLabel{ecmaConformance} | 35 \LMLabel{ecmaConformance} |
36 | 36 |
37 \LMHash{} | 37 \LMHash{} |
38 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 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. |
39 | 39 |
40 \LMHash{} | 40 \LMHash{} |
41 A conforming implementation is permitted to provide additional APIs, but not add itional syntax, except for experimental features in support of null-aware cascad es and tear-offs that are likely to be introduced in the next revision of this s pecification. | 41 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 that are likely to be introduced in the next revision of this specification. |
42 | 42 |
43 \section{Normative References} | 43 \section{Normative References} |
44 \LMLabel{ecmaNormativeReferences} | 44 \LMLabel{ecmaNormativeReferences} |
45 | 45 |
46 \LMHash{} | 46 \LMHash{} |
47 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 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. |
48 | 48 |
49 \begin{enumerate} | 49 \begin{enumerate} |
50 \item | 50 \item |
51 The Unicode Standard, Version 5.0, as amended by Unicode 5.1.0, or successor. | 51 The Unicode Standard, Version 5.0, as amended by Unicode 5.1.0, or successor. |
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2369 . | 2369 . |
2370 \end{grammar} | 2370 \end{grammar} |
2371 | 2371 |
2372 \begin{grammar} | 2372 \begin{grammar} |
2373 {\bf primary:}thisExpression; | 2373 {\bf primary:}thisExpression; |
2374 \SUPER{} unconditionalAssignableSelector; | 2374 \SUPER{} unconditionalAssignableSelector; |
2375 functionExpression; | 2375 functionExpression; |
2376 literal; | 2376 literal; |
2377 identifier; | 2377 identifier; |
2378 newExpression; | 2378 newExpression; |
2379 \NEW{} type `\#' (`{\escapegrammar .}' identifier)?; | |
2380 constObjectExpression; | 2379 constObjectExpression; |
2381 `(' expression `)' | 2380 `(' expression `)' |
2382 . | 2381 . |
2383 | 2382 |
2384 \end{grammar} | 2383 \end{grammar} |
2385 | 2384 |
2386 \LMHash{} | 2385 \LMHash{} |
2387 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$. | 2386 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$. |
2388 | 2387 |
2389 \commentary{ | 2388 \commentary{ |
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4023 \begin{enumerate} | 4022 \begin{enumerate} |
4024 \item A {\em closurization} which converts a method or constructor into a closur e. Or | 4023 \item A {\em closurization} which converts a method or constructor into a closur e. Or |
4025 \item A {\em getter invocation} which returns the result of invoking of a getter method. | 4024 \item A {\em getter invocation} which returns the result of invoking of a getter method. |
4026 \end{enumerate} | 4025 \end{enumerate} |
4027 | 4026 |
4028 | 4027 |
4029 \commentary{Closures derived from members via closurization are colloquially kno wn as tear-offs} | 4028 \commentary{Closures derived from members via closurization are colloquially kno wn as tear-offs} |
4030 | 4029 |
4031 Property extraction can be either {\em conditional} or {\em unconditional}. | 4030 Property extraction can be either {\em conditional} or {\em unconditional}. |
4032 | 4031 |
4033 \rationale { | |
4034 Tear-offs using the \cd{ x\#id} syntax cannot be conditional at this time; this is inconsistent, and is likely to be addressed in the near future, perhaps via notation such as \cd{ x?\#id} . As indicated in section \ref{ecmaConformance}, experimentation in this area is allowed. | |
4035 } | |
4036 | |
4037 Evaluation of a {\em conditional property extraction expression} $e$ of the form $e_1?.id$ is equivalent to the evaluation of the expression $((x) => x == \NU LL ? \NULL : x.id)(e_1)$. | 4032 Evaluation of a {\em conditional property extraction expression} $e$ of the form $e_1?.id$ is equivalent to the evaluation of the expression $((x) => x == \NU LL ? \NULL : x.id)(e_1)$. |
4038 unless $e_1$ is a type literal, in which case it is equivalent to $e_1.m$. | 4033 unless $e_1$ is a type literal, in which case it is equivalent to $e_1.m$. |
4039 | 4034 |
4040 The static type of $e$ is the same as the static type of $e_1.id$. Let $T$ be th e static type of $e_1$ and let $y$ be a fresh variable of type $T$. Exactly the same static warnings that would be caused by $y.id$ are also generated in the ca se of $e_1?.id$. | 4035 The static type of $e$ is the same as the static type of $e_1.id$. Let $T$ be th e static type of $e_1$ and let $y$ be a fresh variable of type $T$. Exactly the same static warnings that would be caused by $y.id$ are also generated in the ca se of $e_1?.id$. |
4041 | 4036 |
4042 \LMHash{} | 4037 \LMHash{} |
4043 Unconditional property extraction takes several syntactic forms: $e.m$ (\ref{get terAccessAndMethodExtraction}), $\SUPER.m$ (\ref{superGetterAccessAndMethodClosu rization}), $e\#m$ (\ref{generalClosurization}), $\NEW{}$ $T\#m$ (\ref{namedCons tructorExtraction}), $\NEW{}$ $T\#$ (\ref{anonymousConstructorExtraction}) and $ \SUPER\#m$ (\ref{generalSuperPropertyExtraction}), where $e$ is an expression, $ m$ is an identifier optionally followed by an equal sign and $T$ is a type. | 4038 Unconditional property extraction has one of two syntactic forms: $e.m$ (\ref{ge tterAccessAndMethodExtraction}) or $\SUPER.m$ (\ref{superGetterAccessAndMethodCl osurization}), where $e$ is an expression and $m$ is an identifier. |
eernst
2016/11/03 13:13:46
I think we still need `optionally followed by an e
Lasse Reichstein Nielsen
2016/11/07 07:49:06
I don't think we need the equals sign - that's the
eernst
2016/11/07 10:08:40
Ah, of course. Acknowledged.
| |
4044 | 4039 |
4045 \subsubsection{Getter Access and Method Extraction} | 4040 \subsubsection{Getter Access and Method Extraction} |
4046 \LMLabel{getterAccessAndMethodExtraction} | 4041 \LMLabel{getterAccessAndMethodExtraction} |
4047 | 4042 |
4048 \LMHash{} | 4043 \LMHash{} |
4049 Evaluation of a property extraction $i$ of the form $e.m$ proceeds as follows: | 4044 Evaluation of a property extraction $i$ of the form $e.m$ proceeds as follows: |
4050 | 4045 |
4051 \LMHash{} | 4046 \LMHash{} |
4052 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}). | 4047 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}). |
4053 | 4048 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4136 Let $S_{static}$ be the superclass of the immediately enclosing class. It is a s tatic type warning if $S_{static}$ does not have an accessible instance method o r getter named $m$. | 4131 Let $S_{static}$ be the superclass of the immediately enclosing class. It is a s tatic type warning if $S_{static}$ does not have an accessible instance method o r getter named $m$. |
4137 | 4132 |
4138 The static type of $i$ is: | 4133 The static type of $i$ is: |
4139 \begin{itemize} | 4134 \begin{itemize} |
4140 \item The declared return type of $S_{static}.m$, if $S_{static}$ has an accessi ble instance getter named $m$. | 4135 \item The declared return type of $S_{static}.m$, if $S_{static}$ has an accessi ble instance getter named $m$. |
4141 \item The static type of function $S_{static}.m$ if $S_{static}$ has an accessib le instance method named $m$. | 4136 \item The static type of function $S_{static}.m$ if $S_{static}$ has an accessib le instance method named $m$. |
4142 \item The type \DYNAMIC{} otherwise. | 4137 \item The type \DYNAMIC{} otherwise. |
4143 \end{itemize} | 4138 \end{itemize} |
4144 | 4139 |
4145 | 4140 |
4146 \subsubsection{General Closurization} | |
4147 \LMLabel{generalClosurization} | |
4148 | |
4149 \LMHash{} | |
4150 Evaluation of a property extraction $i$ of the form $e\#m$ proceeds as follows: | |
4151 | |
4152 \LMHash{} | |
4153 First, the expression $e$ is evaluated to an object $o$. Then: | |
4154 | |
4155 \LMHash{} | |
4156 if $m$ is a setter name, let $f$ be the result of looking up setter $m$ in $o$ with respect to the current library $L$. If $o$ is an instance of \cd{Type} bu t $e$ is not a constant type literal, then if $f$ is a method that forwards to a static setter, setter lookup fails. If setter lookup succeeds then $i$ evaluate s to the closurization of setter $f$ on object $o$ (\ref{ordinaryMemberClosuriza tion}). | |
4157 If setter lookup failed, a \cd{NoSuchMethodError} is thrown. | |
4158 | |
4159 \rationale { | |
4160 It would be more in keeping with the rules of Dart to invoke \cd{noSuchMethod} i n this and similar cases below. However, current implementations of \cd{noSuchM ethod} cannot distinguish between an invocation of a closurization and an actual call. It is likely that future versions of Dart will provide a mechanism to de tect whether \cd{noSuchMethod} is invoked in response to a closurization, say by means of a getter like \cd{isTearOff}. By being conservative at this stage and insisting on failure, we can ensure that no functioning code will break when/if this functionality is introduced. | |
4161 } | |
4162 | |
4163 | |
4164 \LMHash{} | |
4165 If $m$ is not a setter name, let $f$ be the result of looking up method $m$ in $ o$ with respect to the current library $L$. If $o$ is an instance of \cd{Type} but $e$ is not a constant type literal, then if $f$ is a method that forwards t o a static method, method lookup fails. If method lookup succeeds then $i$ evalu ates to the closurization of method $f$ on object $o$ (\ref{ordinaryMemberClosur ization}). | |
4166 | |
4167 \LMHash{} | |
4168 If method lookup failed, let $f$ be the result of looking up getter $m$ in $o$ w ith respect to the current library $L$. If $o$ is an instance of \cd{Type} but $e$ is not a constant type literal, then if $f$ is a method that forwards to a static getter, getter lookup fails. If getter lookup succeeds then $i$ evaluates to the closurization of getter $f$ on object $o$ (\ref{ordinaryMemberClosurizat ion}). | |
4169 If getter lookup failed, a \cd{NoSuchMethodError} is thrown. | |
4170 | |
4171 | |
4172 | |
4173 | |
4174 %\LMHash{} | |
4175 %Otherwise, a new instance $im$ of the predefined class \code{Invocation} is created, such that : | |
4176 %\begin{itemize} | |
4177 %\item If $m$ is a setter name, \code{im.isSetter} evaluates to \code{\TRUE{}}; otherwise \code{im.isMethod} evaluates to \code{\TRUE{}} | |
4178 %\item \code{im.memberName} evaluates to the symbol \code{m}. | |
4179 %\item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} [] }. | |
4180 %\item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
4181 %\end{itemize} | |
4182 %Then the method \code{noSuchMethod()} is looked up in $o$ and invoked with arg ument $im$, and the result of this invocation is the result of evaluating $i$. H owever, if the implementation found cannot be invoked with a single positional a rgument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $o$ with argument $im'$, where $im'$ is an instance of \code{Invocati on} such that : | |
4183 %\begin{itemize} | |
4184 %\item \code{im'.isMethod} evaluates to \code{\TRUE{}}. | |
4185 %\item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. | |
4186 %\item \code{im'.positionalArguments} evaluates to an immutable list whose sole element is $im$. | |
4187 %\item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | |
4188 %\end{itemize} | |
4189 %and the result of this latter invocation is the result of evaluating $i$. | |
4190 | |
4191 \LMHash{} | |
4192 It is a compile-time error if $e$ is a prefix object, $p$, (\ref{imports}) and $ m$ refers to a type accessible via $p$ or to a member of class \cd{Object}. | |
4193 | |
4194 \commentary{ | |
4195 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. | |
4196 } | |
4197 | |
4198 \LMHash{} | |
4199 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: | |
4200 \begin{itemize} | |
4201 \item $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \cd{dart:core}. Or | |
4202 \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$. | |
4203 \item $T$ is \code{Function} and $m$ is \CALL. | |
4204 \end{itemize} | |
4205 | |
4206 The static type of $i$ is: | |
4207 \begin{itemize} | |
4208 \item The static type of function $T.m$, if $T$ has an accessible instance membe r named $m$. | |
4209 \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$. | |
4210 \item \code{Function} if $T$ is \code{Function} and $m$ is \CALL. | |
4211 \item The type \DYNAMIC{} otherwise. | |
4212 \end{itemize} | |
4213 | |
4214 \subsubsection{Named Constructor Extraction} | |
4215 \LMLabel{namedConstructorExtraction} | |
4216 | |
4217 \LMHash{} | |
4218 Evaluation of a property extraction $i$ of the form \NEW{} $T\#m$ proceeds as fo llows: | |
4219 | |
4220 \LMHash{} | |
4221 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}). | |
4222 | |
4223 \commentary{Note that if $T$ is malformed or malbounded, a static warning occurs , as always.} | |
4224 | |
4225 \LMHash{} | |
4226 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{}. | |
4227 | |
4228 It is a compile-time error if $T$ is an enumerated type (\ref{enums}). | |
4229 | |
4230 \subsubsection{Anonymous Constructor Extraction} | |
4231 \LMLabel{anonymousConstructorExtraction} | |
4232 | |
4233 \LMHash{} | |
4234 Evaluation of a property extraction $i$ of the form \NEW{} $T\#$ proceeds as fol lows: | |
4235 | |
4236 \LMHash{} | |
4237 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}). | |
4238 | |
4239 \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.} | |
4240 | |
4241 \LMHash{} | |
4242 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{}. | |
4243 | |
4244 It is a compile-time error if $T$ is an enumerated type (\ref{enums}). | |
4245 | |
4246 | |
4247 \subsubsection{General Super Property Extraction} | |
4248 \LMLabel{generalSuperPropertyExtraction} | |
4249 | |
4250 | |
4251 \LMHash{} | |
4252 Evaluation of a property extraction $i$ of the form \SUPER$\#m$ proceeds as foll ows: | |
4253 | |
4254 \LMHash{} | |
4255 Let $g$ be the method currently executing, and let $C$ be the class in which $g$ was looked up. Let $S_{dynamic}$ be the superclass of $C$. | |
4256 | |
4257 \LMHash{} | |
4258 If $m$ is a setter name, let $f$ be the result of looking up setter $m$ in $S_{d ynamic}$ with respect to the current library $L$. If setter lookup succeeds then $i$ evaluates to the closurization of setter $f$ with respect to superclass $S _{dynamic}$ (\ref{superClosurization}). If setter lookup failed, a \cd{NoSuchM ethodError} is thrown. | |
4259 | |
4260 If $m$ is not a setter name, let $f$ be the result of looking up method $m$ in $ S_{dynamic}$ with respect to the current library $L$. If method lookup succeeds then $i$ evaluates to the closurization of method $m$ with respect to superclass $S_{dynamic}$ (\ref{superClosurization}). | |
4261 | |
4262 \LMHash{} | |
4263 Otherwise, let $f$ be the result of looking up getter $m$ in $S_{dynamic}$ with respect to the current library $L$. If getter lookup succeeds then $i$ evaluat es to the closurization of getter $f$ with respect to superclass $S_{dynamic}$ ( \ref{superClosurization}). If getter lookup failed, a \cd{NoSuchMethodError} i s thrown. | |
4264 | |
4265 \LMHash{} | |
4266 Let $S_{static}$ be the superclass of the immediately enclosing class.It is a st atic type warning if $S_{static}$ does not have an accessible instance member na med $m$. | |
4267 | |
4268 \LMHash{} | |
4269 The static type of $i$ is the static type of the function $S_{static}.m$, if $S _{static}$ has an accessible instance member named $m$. Otherwise the static typ e of $i$ is \DYNAMIC{}. | |
4270 | |
4271 | |
4272 | |
4273 \subsubsection{Ordinary Member Closurization} | 4141 \subsubsection{Ordinary Member Closurization} |
4274 \LMLabel{ordinaryMemberClosurization} | 4142 \LMLabel{ordinaryMemberClosurization} |
4275 | 4143 |
4276 | |
4277 \LMHash{} | 4144 \LMHash{} |
4278 Let $o$ be an object, and let $u$ be a fresh final variable bound to $o$. | 4145 Let $o$ be an object, and let $u$ be a fresh final variable bound to $o$. |
4279 The {\em closurization of method $f$ on object $o$} is defined to be equivalent to: | 4146 The {\em closurization of method $f$ on object $o$} is defined to be equivalent to: |
4280 \begin{itemize} | 4147 \begin{itemize} |
4281 \item $(a) \{\RETURN{}$ $u$ $op$ $a;$\} if $f$ is named $op$ and $op$ is one of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<<$, $> >$} (this precludes closurization of unary -). | 4148 %\item $(a) \{\RETURN{}$ $u$ $op$ $a;$\} if $f$ is named $op$ and $op$ is one of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<<$, $ >>$} (this precludes closurization of unary -). |
4282 \item $() \{\RETURN{}$ \~{} $u;$\} if $f$ is named \~{}. | 4149 %\item $() \{\RETURN{}$ \~{} $u;$\} if $f$ is named \~{}. |
4283 \item $(a) \{\RETURN{}$ $u[a];$\} if $f$ is named $[]$. | 4150 %\item $(a) \{\RETURN{}$ $u[a];$\} if $f$ is named $[]$. |
4284 \item $(a, b) \{\RETURN{}$ $u[a] = b;$\} if $f$ is named $[]=$. | 4151 %\item $(a, b) \{\RETURN{}$ $u[a] = b;$\} if $f$ is named $[]=$. |
4285 \item | 4152 \item |
4286 \begin{dartCode} | 4153 \begin{dartCode} |
4287 $(r_1, \ldots, r_n, \{p_1 = d_1, \ldots , p_k = d_k\})$ \{ | 4154 $(r_1, \ldots, r_n, \{p_1 = d_1, \ldots , p_k = d_k\})$ \{ |
4288 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | 4155 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ |
4289 \} | 4156 \} |
4290 \end{dartCode} | 4157 \end{dartCode} |
4291 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$. | 4158 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$. |
eernst
2016/11/03 13:13:46
Is it really true that closurization should drop t
Lasse Reichstein Nielsen
2016/11/07 07:49:06
No.
We should fix it. The extracted function shoul
| |
4292 \item | 4159 \item |
4293 \begin{dartCode} | 4160 \begin{dartCode} |
4294 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | 4161 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ |
4295 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | 4162 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; |
4296 \} | 4163 \} |
4297 \end{dartCode} | 4164 \end{dartCode} |
4298 | |
4299 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$. | 4165 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$. |
4300 \end{itemize} | 4166 %\end{itemize} |
4301 | 4167 |
4302 \LMHash{} | 4168 \LMHash{} |
4303 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$} . | 4169 Except that iff \code{identical($o_1, o_2$)} then \cd{$o_1.m$ == $o_2.m$}. |
4304 %\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{}. | 4170 %\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{}. |
4305 | 4171 |
4306 \LMHash{} | |
4307 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$}. | |
4308 | |
4309 \LMHash{} | |
4310 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=$}. | |
4311 | |
4312 \commentary{ | 4172 \commentary{ |
4313 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. | 4173 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. |
4314 } | 4174 } |
4315 % local functions that have a closure extracted are always different | 4175 % local functions that have a closure extracted are always different |
4316 | 4176 |
4317 \rationale{ | 4177 \rationale{ |
4318 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. | 4178 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. |
4319 } | 4179 } |
4320 | 4180 |
4321 \commentary { | |
4322 Observations: | |
4323 | |
4324 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. | |
4325 } | |
4326 | |
4327 | |
4328 | |
4329 \subsubsection{Named Constructor Closurization} | |
4330 \LMLabel{namedConstructorClosurization} | |
4331 | |
4332 \LMHash{} | |
4333 The {\em closurization of constructor $f$ of type $T$} is defined to be equivale nt to: | |
4334 \begin{itemize} | |
4335 \item | |
4336 \begin{dartCode} | |
4337 $(r_1, \ldots, r_n, \{p_1 = d_1, \ldots , p_k = d_k\})$ \{ | |
4338 \RETURN{} \NEW{} $T.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | |
4339 \} | |
4340 \end{dartCode} | |
4341 | |
4342 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$. | |
4343 \item | |
4344 \begin{dartCode} | |
4345 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | |
4346 \RETURN{} \NEW{} $T.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | |
4347 \} | |
4348 \end{dartCode} | |
4349 | |
4350 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$. | |
4351 \end{itemize} | |
4352 | |
4353 \LMHash{} | |
4354 Except that iff \code{identical($T_1, T_2$)} then \cd{\NEW{} $T_1\#m$ == \NEW {} $T_2\#m$}. | |
4355 | |
4356 \commentary{ | |
4357 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. | |
4358 } | |
4359 | |
4360 \subsubsection{Anonymous Constructor Closurization} | |
4361 \LMLabel{anonymousConstructorClosurization} | |
4362 | |
4363 \LMHash{} | |
4364 The {\em closurization of anonymous constructor $f$ of type $T$} is defined to b e equivalent to: | |
4365 \begin{itemize} | |
4366 \item | |
4367 \begin{dartCode} | |
4368 $(r_1, \ldots, r_n, \{p_1 = d_1, \ldots , p_k = d_k\})$ \{ | |
4369 \RETURN{} \NEW{} $T(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | |
4370 \} | |
4371 \end{dartCode} | |
4372 | |
4373 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$. | |
4374 \item | |
4375 \begin{dartCode} | |
4376 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | |
4377 \RETURN{} \NEW{} $T(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | |
4378 \} | |
4379 \end{dartCode} | |
4380 | |
4381 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$. | |
4382 \end{itemize} | |
4383 | |
4384 \LMHash{} | |
4385 Except that iff \code{identical($T_1, T_2$)} then \cd{\NEW{} $T_1\#$ == \NEW{ } $T_2\#$}. | |
4386 | |
4387 | |
4388 \subsubsection{Super Closurization} | 4181 \subsubsection{Super Closurization} |
4389 \LMLabel{superClosurization} | 4182 \LMLabel{superClosurization} |
4390 | 4183 |
4391 \LMHash{} | 4184 \LMHash{} |
4392 The {\em closurization of method $f$ with respect to superclass $S$} is defined to be equivalent to: | 4185 The {\em closurization of method $f$ with respect to superclass $S$} is defined to be equivalent to: |
4393 | 4186 |
4394 \LMHash{} | 4187 \LMHash{} |
4395 \begin{itemize} | 4188 \begin{itemize} |
4396 \item $(a) \{\RETURN{}$ \SUPER{} $op$ $a;$\} if $f$ is named $op$ and $op$ is on e of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<< $, $>>$}. | 4189 %\item $(a) \{\RETURN{}$ \SUPER{} $op$ $a;$\} if $f$ is named $op$ and $op$ is o ne of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $< <$, $>>$}. |
4397 \item $() \{\RETURN{}$ \~{}\SUPER;\} if $f$ is named \~{}. | 4190 %\item $() \{\RETURN{}$ \~{}\SUPER;\} if $f$ is named \~{}. |
4398 \item $(a) \{\RETURN{}$ $\SUPER[a];$\} if $f$ is named $[]$. | 4191 %\item $(a) \{\RETURN{}$ $\SUPER[a];$\} if $f$ is named $[]$. |
4399 \item $(a, b) \{\RETURN{}$ $\SUPER[a] = b;$\} if $f$ is named $[]=$. | 4192 %\item $(a, b) \{\RETURN{}$ $\SUPER[a] = b;$\} if $f$ is named $[]=$. |
4400 \item | 4193 \item |
4401 \begin{dartCode} | 4194 \begin{dartCode} |
4402 $(r_1, \ldots, r_n, \{p_1 = d_1, \ldots , p_k = d_k\})$ \{ | 4195 $(r_1, \ldots, r_n, \{p_1 = d_1, \ldots , p_k = d_k\})$ \{ |
4403 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ | 4196 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ |
4404 \} | 4197 \} |
4405 \end{dartCode} | 4198 \end{dartCode} |
4406 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$. | 4199 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$. |
eernst
2016/11/03 13:13:46
Same issue as last time, with the missing argument
| |
4407 \item | 4200 \item |
4408 \begin{dartCode} | 4201 \begin{dartCode} |
4409 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ | 4202 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ |
4410 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; | 4203 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; |
4411 \} | 4204 \} |
4412 \end{dartCode} | 4205 \end{dartCode} |
4413 | |
4414 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$. | 4206 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$. |
4415 \end{itemize} | 4207 \end{itemize} |
4416 | 4208 |
4417 \LMHash{} | 4209 \LMHash{} |
4418 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$}. | 4210 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$}. |
4419 | |
4420 | |
4421 \LMHash{} | |
4422 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$}. | |
4423 | |
4424 \LMHash{} | |
4425 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=$}. | |
4426 | |
4427 | 4211 |
4428 | 4212 |
4429 \subsection{ Assignment} | 4213 \subsection{ Assignment} |
4430 \LMLabel{assignment} | 4214 \LMLabel{assignment} |
4431 | 4215 |
4432 \LMHash{} | 4216 \LMHash{} |
4433 An assignment changes the value associated with a mutable variable or property. | 4217 An assignment changes the value associated with a mutable variable or property. |
4434 | 4218 |
4435 \begin{grammar} | 4219 \begin{grammar} |
4436 {\bf assignmentOperator:}`=' ; | 4220 {\bf assignmentOperator:}`=' ; |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5048 | 4832 |
5049 | 4833 |
5050 \subsection{ Postfix Expressions} | 4834 \subsection{ Postfix Expressions} |
5051 \LMLabel{postfixExpressions} | 4835 \LMLabel{postfixExpressions} |
5052 | 4836 |
5053 \LMHash{} | 4837 \LMHash{} |
5054 Postfix expressions invoke the postfix operators on objects. | 4838 Postfix expressions invoke the postfix operators on objects. |
5055 | 4839 |
5056 \begin{grammar} | 4840 \begin{grammar} |
5057 {\bf postfixExpression:}assignableExpression postfixOperator; | 4841 {\bf postfixExpression:}assignableExpression postfixOperator; |
5058 primary (selector* $|$ ( `\#' ( (identifier `='?) $|$ operator))) | 4842 primary selector* |
5059 . | 4843 . |
5060 | 4844 |
5061 {\bf postfixOperator:} | 4845 {\bf postfixOperator:} |
5062 incrementOperator | 4846 incrementOperator |
5063 . | 4847 . |
5064 | 4848 |
5065 {\bf selector:}assignableSelector; | 4849 {\bf selector:}assignableSelector; |
5066 arguments | 4850 arguments |
5067 . | 4851 . |
5068 | 4852 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5304 | 5088 |
5305 \LMHash{} | 5089 \LMHash{} |
5306 Evaluation of an identifier expression $e$ of the form $id$ proceeds as follows: | 5090 Evaluation of an identifier expression $e$ of the form $id$ proceeds as follows: |
5307 | 5091 |
5308 | 5092 |
5309 \LMHash{} | 5093 \LMHash{} |
5310 Let $d$ be the innermost declaration in the enclosing lexical scope whose name i s $id$ or $id=$. If no such declaration exists in the lexical scope, let $d$ be the declaration of the inherited member named $id$ if it exists. | 5094 Let $d$ be the innermost declaration in the enclosing lexical scope whose name i s $id$ or $id=$. If no such declaration exists in the lexical scope, let $d$ be the declaration of the inherited member named $id$ if it exists. |
5311 %If no such member exists, let $d$ be the declaration of the static member name $id$ declared in a superclass of the current class, if it exists. | 5095 %If no such member exists, let $d$ be the declaration of the static member name $id$ declared in a superclass of the current class, if it exists. |
5312 | 5096 |
5313 \begin{itemize} | 5097 \begin{itemize} |
5314 \item if $d$ is a prefix $p$, a compile-time error occurs unless the token immed iately following $d$ is \code{'.'} or \code{'\#'}. | 5098 \item if $d$ is a prefix $p$, a compile-time error occurs unless the token immed iately following $d$ is \code{'.'}. |
5315 \item If $d$ is a class or type alias $T$, the value of $e$ is an instance of c lass \code{Type} (or a subclass thereof) reifying $T$. | 5099 \item If $d$ is a class or type alias $T$, the value of $e$ is an instance of c lass \code{Type} (or a subclass thereof) reifying $T$. |
5316 \item If $d$ is a type parameter $T$, then the value of $e$ is the value of the actual type argument corresponding to $T$ that was passed to the generative con structor that created the current binding of \THIS{}. If, however, $e$ occurs in side a static member, a compile-time error occurs. | 5100 \item If $d$ is a type parameter $T$, then the value of $e$ is the value of the actual type argument corresponding to $T$ that was passed to the generative con structor that created the current binding of \THIS{}. If, however, $e$ occurs in side a static member, a compile-time error occurs. |
5317 | 5101 |
5318 %\commentary{ We are assured that \THIS{} is well defined, because if we were in a static member the reference to $T$ is a compile-time error (\ref{generics}.)} | 5102 %\commentary{ We are assured that \THIS{} is well defined, because if we were in a static member the reference to $T$ is a compile-time error (\ref{generics}.)} |
5319 %\item If $d$ is a library variable then: | 5103 %\item If $d$ is a library variable then: |
5320 % \begin{itemize} | 5104 % \begin{itemize} |
5321 % \item If $d$ is of one of the forms \code{\VAR{} $v$ = $e_i$;} , \code{$T$ $v $ = $e_i$;} , \code{\FINAL{} $v$ = $e_i$;} or \code{\FINAL{} $T$ $v$ = $e_i$;} and no value has yet been stored into $v$ then the initializer expression $e_i$ is evaluated. If, during the evaluation of $e_i$, the getter for $v$ is referenc ed, a \code{CyclicInitializationError} is thrown. If the evaluation succeeded yi elding an object $o$, let $r = o$, otherwise let $r = \NULL{}$. In any case, $r$ is stored into $v$. The value of $e$ is $r$. | 5105 % \item If $d$ is of one of the forms \code{\VAR{} $v$ = $e_i$;} , \code{$T$ $v $ = $e_i$;} , \code{\FINAL{} $v$ = $e_i$;} or \code{\FINAL{} $T$ $v$ = $e_i$;} and no value has yet been stored into $v$ then the initializer expression $e_i$ is evaluated. If, during the evaluation of $e_i$, the getter for $v$ is referenc ed, a \code{CyclicInitializationError} is thrown. If the evaluation succeeded yi elding an object $o$, let $r = o$, otherwise let $r = \NULL{}$. In any case, $r$ is stored into $v$. The value of $e$ is $r$. |
5322 \item If $d$ is a constant variable of one of the forms \code{\CONST{} $v$ = $e$;} or \code{\CONST{} $T$ $v$ = $e$;} then the value $id$ is the value of the compile-time constant $e$. | 5106 \item If $d$ is a constant variable of one of the forms \code{\CONST{} $v$ = $e$;} or \code{\CONST{} $T$ $v$ = $e$;} then the value $id$ is the value of the compile-time constant $e$. |
5323 % Otherwise | 5107 % Otherwise |
5324 % \item $e$ evaluates to the current binding of $id$. | 5108 % \item $e$ evaluates to the current binding of $id$. |
(...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7915 | 7699 |
7916 The invariant that each normative paragraph is associated with a line | 7700 The invariant that each normative paragraph is associated with a line |
7917 containing the text \LMHash{} should be maintained. Extra occurrences | 7701 containing the text \LMHash{} should be maintained. Extra occurrences |
7918 of \LMHash{} can be added if needed, e.g., in order to make | 7702 of \LMHash{} can be added if needed, e.g., in order to make |
7919 individual \item{}s in itemized lists addressable. Each \LM.. command | 7703 individual \item{}s in itemized lists addressable. Each \LM.. command |
7920 must occur on a separate line. \LMHash{} must occur immediately | 7704 must occur on a separate line. \LMHash{} must occur immediately |
7921 before the associated paragraph, and \LMLabel must occur immediately | 7705 before the associated paragraph, and \LMLabel must occur immediately |
7922 after the associated \section{}, \subsection{} etc. | 7706 after the associated \section{}, \subsection{} etc. |
7923 | 7707 |
7924 ---------------------------------------------------------------------- | 7708 ---------------------------------------------------------------------- |
OLD | NEW |