Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: docs/language/dartLangSpec.tex

Issue 2433943002: Spec: Rewrite lambdas to simpler semantics instead. (Closed)
Patch Set: Remove \LET Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« docs/language/dart.sty ('K') | « docs/language/dart.sty ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 It is a compile-time error if a class has an instance member and a static member with the same name. 921 It is a compile-time error if a class has an instance member and a static member with the same name.
922 % It is a compile-time error if a generic (\ref{generics}) class declares a memb er with the same name as one of its type parameters. 922 % It is a compile-time error if a generic (\ref{generics}) class declares a memb er with the same name as one of its type parameters.
923 923
924 \commentary{Here are simple examples, that illustrate the difference between ``h as a member'' and ``declares a member''. For example, \code{B} {\em declares} on e member named \code{f}, but {\em has} two such members. The rules of inheritanc e determine what members a class has. 924 \commentary{Here are simple examples, that illustrate the difference between ``h as a member'' and ``declares a member''. For example, \code{B} {\em declares} on e member named \code{f}, but {\em has} two such members. The rules of inheritanc e determine what members a class has.
925 } 925 }
926 926
927 \begin{dartCode} 927 \begin{dartCode}
928 \CLASS{} A \{ 928 \CLASS{} A \{
929 \VAR{} i = 0; 929 \VAR{} i = 0;
930 \VAR{} j; 930 \VAR{} j;
931 f(x) =$>$ 3; 931 f(x) $=>$ 3;
eernst 2016/11/03 18:07:05 The `dartCode` environment shows source code in a
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Ack. I don't like physical formatting. I'd prefer
932 \} 932 \}
933 933
934 \CLASS{} B \EXTENDS{} A \{ 934 \CLASS{} B \EXTENDS{} A \{
935 int i = 1; // getter i and setter i= override versions from A 935 int i = 1; // getter i and setter i= override versions from A
936 \STATIC{} j; // compile-time error: static getter \& setter conflict with 936 \STATIC{} j; // compile-time error: static getter \& setter conflict with
937 //instance getter \& setter 937 //instance getter \& setter
938 938
939 /* compile-time error: static method conflicts with instance method */ 939 /* compile-time error: static method conflicts with instance method */
940 \STATIC{} f(x) =$>$ 3; 940 \STATIC{} f(x) $=>$ 3;
eernst 2016/11/03 18:07:06 Just keep the old version.
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
941 \} 941 \}
942 \end{dartCode} 942 \end{dartCode}
943 943
944 \LMHash{} 944 \LMHash{}
945 It is a compile time error if a class $C$ declares a member with the same name a s $C$. It is a compile time error if a generic class declares a type variable wi th the same name as the class or any of its members or constructors. 945 It is a compile time error if a class $C$ declares a member with the same name a s $C$. It is a compile time error if a generic class declares a type variable wi th the same name as the class or any of its members or constructors.
946 946
947 \subsection{Instance Methods} 947 \subsection{Instance Methods}
948 \LMLabel{instanceMethods} 948 \LMLabel{instanceMethods}
949 949
950 \LMHash{} 950 \LMHash{}
(...skipping 2870 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 \LMHash{} 3821 \LMHash{}
3822 An ordinary method invocation can be {\em conditional} or {\em unconditional}. 3822 An ordinary method invocation can be {\em conditional} or {\em unconditional}.
3823 3823
3824 \LMHash{} 3824 \LMHash{}
3825 Evaluation of a {\em conditional ordinary method invocation} $e$ of the form 3825 Evaluation of a {\em conditional ordinary method invocation} $e$ of the form
3826 3826
3827 \LMHash{} 3827 \LMHash{}
3828 $o?.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ 3828 $o?.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$
3829 3829
3830 \LMHash{} 3830 \LMHash{}
3831 is equivalent to the evaluation of the expression 3831 proceeds as follows:
3832 3832
3833 \LMHash{} 3833 \LMHash{}
3834 $((x) => x == \NULL ? \NULL : x.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}))(o)$. 3834 If $o$ is not a type literal, evaluate $o$ to an object $x$.
3835 If $x$ is the null value, $e$ evaluates to the null value.
eernst 2016/11/03 18:07:06 This is confusing because the scope of the first `
Lasse Reichstein Nielsen 2016/11/08 11:42:34 changed to expression $i$ on the form $e.m(...)$ a
3836 Otherwise let \code{v} be a fresh variable bound to $x$ and evaluate
Lasse Reichstein Nielsen 2016/10/31 07:39:25 As discussed offline, the \code{v} should be $v$ -
eernst 2016/11/03 18:07:06 Acknowledged.
3837 \code{v.m($a_1$, $\ldots$ , $a_n$, $x_{n+1}$: $a_{n+1}$, $\ldots$ , $x_{n+k}$: $ a_{n+k}$))} to a value $r$, and then $e$ evaluates to $r$.
3835 3838
3836 unless $o$ is a type literal, in which case it is equivalent to $o.m(a_1, \ldot s , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3839 If $o$ is a type literal, $e$ is equivalent to $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3837 3840
3838 \LMHash{} 3841 \LMHash{}
3839 The static type of $e$ is the same as the static type of $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. Exactly the same static warnings that would be caused by $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n +k}: a_{n+k})$ are also generated in the case of $o?.m(a_1, \ldots , a_n, x_{n+1 }: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3842 The static type of $e$ is the same as the static type of $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. Exactly the same static warnings that would be caused by $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n +k}: a_{n+k})$ are also generated in the case of $o?.m(a_1, \ldots , a_n, x_{n+1 }: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3840 3843
3841 \LMHash{} 3844 \LMHash{}
3842 An {\em unconditional ordinary method invocation} $i$ has the form 3845 An {\em unconditional ordinary method invocation} $i$ has the form
3843 3846
3844 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3847 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3845 3848
3846 \LMHash{} 3849 \LMHash{}
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 {\bf cascadeSection:} 3936 {\bf cascadeSection:}
3934 `{\escapegrammar ..}' (cascadeSelector arguments*) (assignableSelector arg uments*)* (assignmentOperator expressionWithoutCascade)? 3937 `{\escapegrammar ..}' (cascadeSelector arguments*) (assignableSelector arg uments*)* (assignmentOperator expressionWithoutCascade)?
3935 . 3938 .
3936 3939
3937 {\bf cascadeSelector:}`[' expression `]'; 3940 {\bf cascadeSelector:}`[' expression `]';
3938 identifier 3941 identifier
3939 . 3942 .
3940 \end{grammar} 3943 \end{grammar}
3941 3944
3942 \LMHash{} 3945 \LMHash{}
3943 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$)}. 3946 Evaluation of a cascaded method invocation expression $e$ of the form \code{e..s uffix} proceeds as follows:
eernst 2016/11/03 18:07:05 We ought to use meta-variables here: `\code{$e$..\
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Physical formatting :( I added a new def so I can
3947
3948 Evaluate \code{e} to an object $o$.
eernst 2016/11/03 18:07:03 `\code{e}` --> `$e$`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
3949 Let $t$ be a fresh variable bound to $o$.
3950 Evaluate $t.suffix$ to an object.
eernst 2016/11/03 18:07:06 `$t.suffix$` --> `\code{$t$.\mbox{\em suffix}}` ju
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
3951 Then $e$ evaluates to $o$.
3944 3952
3945 \rationale{ 3953 \rationale{
3946 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$)}. 3954 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 == \NULL{} ? \NULL{} : t.{\em suffix}} where \code{t} is bound to the value of $e$.
eernst 2016/11/03 18:07:06 might as well say `$t$ is a fresh variable bound t
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
3947 3955
3948 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}. 3956 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}.
3949 } 3957 }
3950 3958
3951 \subsubsection{Super Invocation} 3959 \subsubsection{Super Invocation}
3952 \LMLabel{superInvocation} 3960 \LMLabel{superInvocation}
3953 3961
3954 \LMHash{} 3962 \LMHash{}
3955 A super method invocation $i$ has the form 3963 A super method invocation $i$ has the form
3956 3964
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4027 4035
4028 4036
4029 \commentary{Closures derived from members via closurization are colloquially kno wn as tear-offs} 4037 \commentary{Closures derived from members via closurization are colloquially kno wn as tear-offs}
4030 4038
4031 Property extraction can be either {\em conditional} or {\em unconditional}. 4039 Property extraction can be either {\em conditional} or {\em unconditional}.
4032 4040
4033 \rationale { 4041 \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. 4042 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 } 4043 }
4036 4044
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)$. 4045 If $e_1$ is not a type literal, evaluation of a {\em conditional property extrac tion expression} $e$ of the form $e_1?.id$ proceeds as follows:
eernst 2016/11/03 18:07:05 I think it would be useful to reorganize this a bi
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
4038 unless $e_1$ is a type literal, in which case it is equivalent to $e_1.m$. 4046
4047 Evaluate $e_1$ to an object $o$.
4048 If $o$ is the null value, $e$ evaluates to the null value.
4049 Otherwise let $x$ be a fresh variable bound to $o$ and evaluate \code{$x$.id} to a value $r$.
eernst 2016/11/03 18:07:03 `$x$.$id$`.
Lasse Reichstein Nielsen 2016/11/08 11:42:34 \code{$e_1$.\metavar{id}} Logical formatting FTW!
4050 Then $e$ evaluates to $r$.
4051
4052 If $e_1$ is a type literal, $e$ is equivalent to $e_1.m$.
eernst 2016/11/03 18:07:06 (If the reorg above is performed, this line is mov
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Acknowledged.
4039 4053
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$. 4054 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 4055
4042 \LMHash{} 4056 \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. 4057 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.
4044 4058
4045 \subsubsection{Getter Access and Method Extraction} 4059 \subsubsection{Getter Access and Method Extraction}
4046 \LMLabel{getterAccessAndMethodExtraction} 4060 \LMLabel{getterAccessAndMethodExtraction}
4047 4061
4048 \LMHash{} 4062 \LMHash{}
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
4472 \LMHash{} 4486 \LMHash{}
4473 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. 4487 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}.
4474 4488
4475 \LMHash{} 4489 \LMHash{}
4476 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$. 4490 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$.
4477 4491
4478 \LMHash{} 4492 \LMHash{}
4479 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$. 4493 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$.
4480 4494
4481 \LMHash{} 4495 \LMHash{}
4482 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 )$ 4496 Evaluation of an assignment $a$ of the form \code{$e_1$?.v = $e_2$}
eernst 2016/11/03 18:07:06 If we keep metavariables in math mode, it should b
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
4483 unless $e_1$ is a type literal, in which case it is equivalent to $e_1.v$ \cod e{=} $e_2$. 4497 proceeds as follows:
4484 . The static type of $a$ is the static type of $e_2$. Let $T$ be the static type of $e_1$ and let $y$ be a fresh variable of type $T$. Exactly the same static w arnings that would be caused by $y.v = e_2$ are also generated in the case of $e _1?.v$ \code{=} $e_2$. 4498
4499 If $e_1$ is not a type literal, evaluate $e_1$ to an object $o$.
4500 If $o$ is the null value, $a$ evaluates to the null value.
4501 Otherwise let $x$ be a fresh variable bound to $o$ and evaluate \code{$o$.v = $e _2$} to an object $r$.
eernst 2016/11/03 18:07:04 `\code{$o$.$v$ = $e_2$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4502 Then $a$ evaluates to $r$.
4503
4504 If $e_1$ is a type literal, $a$ is equivalent to $e_1.v$ \code{=} $e_2$.
eernst 2016/11/03 18:07:04 We could reorganize this as well, both for consist
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4505
4506 The static type of $a$ is the static type of $e_2$. Let $T$ be the static type o f $e_1$ and let $y$ be a fresh variable of type $T$. Exactly the same static war nings that would be caused by $y.v = e_2$ are also generated in the case of $e_1 ?.v$ \code{=} $e_2$.
4485 4507
eernst 2016/11/03 18:07:06 It's probably difficult to tell, but `\code{$y$.$v
4486 \LMHash{} 4508 \LMHash{}
4487 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws: 4509 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws:
4488 4510
4489 \LMHash{} 4511 \LMHash{}
4490 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$. 4512 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$.
4491 4513
4492 \LMHash{} 4514 \LMHash{}
4493 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : 4515 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that :
4494 \begin{itemize} 4516 \begin{itemize}
4495 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. 4517 \item \code{im.isSetter} evaluates to \code{\TRUE{}}.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
4563 4585
4564 \LMHash{} 4586 \LMHash{}
4565 It is a static type warning if the static type of $e$ may not be assigned to the static type of the formal parameter of the setter $v=$. The static type of th e expression $\SUPER.v$ \code{=} $e$ is the static type of $e$. 4587 It is a static type warning if the static type of $e$ may not be assigned to the static type of the formal parameter of the setter $v=$. The static type of th e expression $\SUPER.v$ \code{=} $e$ is the static type of $e$.
4566 4588
4567 4589
4568 4590
4569 4591
4570 4592
4571 4593
4572 \LMHash{} 4594 \LMHash{}
4573 Evaluation of an assignment of the form $e_1[e_2]$ \code{=} $e_3$ is equivalent to the evaluation of the expression \code{(a, i, e)\{a.[]=(i, e); \RETURN{} e; \ } ($e_1, e_2, e_3$)}. The static type of the expression $e_1[e_2]$ \code{=} $e_ 3$ is the static type of $e_3$. 4595 Evaluation of an assignment $e$ of the form \code{$e_1$[$e_2$] = $e_3$}
4596 proceeds as follows:
4597
4598 Evaluate $e_1$ to an object $a$, then evaluate $e_2$ to an object $i$, and final ly evaluate $e_3$ to an object $v$.
4599 Call the method $[]=$ on $a$ with $i$ as first argument and $v$ as second argume nt.
eernst 2016/11/03 18:07:04 The method name is actually concrete syntax, so th
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4600 Then $e$ evaluates to $v$.
4601
4602 The static type of the expression $e_1[e_2]$ \code{=} $e_3$ is the static type o f $e_3$.
eernst 2016/11/03 18:07:04 `\code{$e_1$[$e_2$] = $e_3$}` would be the consist
Lasse Reichstein Nielsen 2016/11/08 11:42:33 I'm all for consistency.
4574 4603
4575 \LMHash{} 4604 \LMHash{}
4576 An assignment of the form $\SUPER[e_1]$ \code{=} $e_2$ is equivalent to the expr ession $\SUPER.[e_1]$ \code{=} $e_2$. The static type of the expression $\SUPER [e_1]$ \code{=} $e_2$ is the static type of $e_2$. 4605 An assignment of the form \code{\SUPER[$e_1$] = $e_2$} is equivalent to the expr ession \code{\SUPER.[$e_1$] = $e_2$}. The static type of the expression \code{\ SUPER[$e_1$] = $e_2$} is the static type of $e_2$.
4577 4606
4578 4607
4579 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map. 4608 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map.
4580 4609
4581 \LMHash{} 4610 \LMHash{}
4582 It is a static warning if an assignment of the form $v = e$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer and there is neither a local variable declaration with name $v$ no r setter declaration with name $v=$ in the lexical scope enclosing the assignmen t. 4611 It is a static warning if an assignment of the form $v = e$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer and there is neither a local variable declaration with name $v$ no r setter declaration with name $v=$ in the lexical scope enclosing the assignmen t.
4583 4612
4584 \LMHash{} 4613 \LMHash{}
4585 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 `.'. 4614 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 `.'.
4586 4615
4587 4616
4588 4617
4589 \subsubsection{Compound Assignment} 4618 \subsubsection{Compound Assignment}
4590 \LMLabel{compoundAssignment} 4619 \LMLabel{compoundAssignment}
4591 4620
4592 \LMHash{} 4621 \LMHash{}
4593 Evaluation of a compound assignment of the form $v$ {\em ??=} $e$ is equivalent to the evaluation of the expression $((x) => x == \NULL{}$ ? $v=e : x)(v)$ whe re $x$ is a fresh variable that is not used in $e$. 4622 Evaluation of a compound assignment $a$ of the form $v$ {\em ??=} $e$
eernst 2016/11/03 18:07:06 I'd say `of the form \code{$v$ ??= $e$}`.
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
4623 proceeds as follows:
4624
4625 Evaluate $v$ to an object $o$.
4626 If $o$ is not the null value, $a$ evaluates to $o$.
4627 Otherwise evaluate \code{$v$ = $e$} to a value $r$,
4628 and then $a$ evaluates to $r$.
4594 4629
4595 \LMHash{} 4630 \LMHash{}
4596 Evaluation of a compound assignment of the form $C.v$ {\em ??=} $e$, where $C$ i s a type literal, is equivalent to the evaluation of the expression $((x) => x == \NULL{}$? $C.v=e: x)(C.v)$ where $x$ is a fresh variable that is not used in $e$. 4631 Evaluation of a compound assignment, $a$ of the form $C.v$ {\em ??=} $e$, where $C$ is a type literal, proceeds as follow:
eernst 2016/11/03 18:07:03 `of the form \code{$C$.$v$ ??= $e$}, ..`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
4632
4633 Evaluate $C.v$ to an object $o$.
4634 If $o$ is not the null value, $a$ evaluates to $o$.
4635 Otherwise evaluate \code{$C.v$ = $e$} to a value $r$,
4636 and then $a$ evaluates to $r$.
4597 4637
4598 \commentary { 4638 \commentary {
4599 The two rules above also apply when the variable v or the type C is prefixed. 4639 The two rules above also apply when the variable v or the type C is prefixed.
4600 } 4640 }
4601 4641
4602 \LMHash{} 4642 \LMHash{}
4603 Evaluation of a compound assignment of the form $e_1.v$ {\em ??=} $e_2$ is equiv alent to the evaluation of the expression $((x) =>((y) => y == \NULL{}$ ? $ x.v = e_2: y)(x.v))(e_1)$ where $x$ and $y$ are distinct fresh variables that are n ot used in $e_2$. 4643 Evaluation of a compound assignment $a$ of the form $e_1.v$ {\em ??=} $e_2$
eernst 2016/11/03 18:07:03 `of the form \code{$e_1$.$v$ ??= $e_2$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
4644 proceeds as follows:
4645
4646 Evaluate $e_1$ to an object $u$.
4647 Let \code{x} be a fresh variable not occuring in $e_2$ and bound to $u$.
eernst 2016/11/03 18:07:07 `$x$`, `occuring` --> `occurring`, but it's not fr
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4648 Evalute \code{x.$v$} to an object $o$.
eernst 2016/11/03 18:07:04 `\code{$x$.$v$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
4649 If $o$ is not the null value, $a$ evaluates to $o$.
4650 Otherwise evaluate \code{x.$v$ = $e_2$} to an object $r$,
eernst 2016/11/03 18:07:04 `\code{$x$.$v$ = $e_2$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4651 and then $a$ evaluates to $r$.
4604 4652
4605 \LMHash{} 4653 \LMHash{}
4606 Evaluation of a compound assignment of the form $e_1[e_2]$ {\em ??=} $e_3$ is equivalent to the evaluation of the expression 4654 Evaluation of a compound assignment $a$ of the form $e_1[e_2]$ {\em ??=} $e_3$
eernst 2016/11/03 18:07:05 `\code{$e_1$[$e_2$] ??= $e_3$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
4607 $((a, i) => ((x) => x == \NULL{}$ ? $a[i] = e_3: x)(a[i]))(e_1, e_2)$ where $x$ , $a$ and $i$ are distinct fresh variables that are not used in $e_3$. 4655 proceeds as follows:
4656
4657 Evaluate $e_1$ to an object $u$ and then evaluate $e_2$ to an object $i$.
4658 Call the $[]$ method on $u$ with argument $i$ and let $o$ be the returned value.
eernst 2016/11/03 18:07:04 `\code{[]}`, add comma: `argument $i$, and let`
Lasse Reichstein Nielsen 2016/11/08 11:42:33 Done.
4659 If $o$ is not the null value, $a$ evaluates to $o$.
4660 Otherwise evaluate $e_3$ to an object $v$
4661 and then call the $[]=$ method on $u$ with $i$ as first argument and $v$ as seco nd argument.
eernst 2016/11/03 18:07:04 `\code{[]=}`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4662 Then $a$ evaluates to $v$.
4608 4663
4609 \LMHash{} 4664 \LMHash{}
4610 Evaluation of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is equ ivalent to the evaluation of the expression $((x) => x == \NULL{}$ ? $\SUPER.v = e: x)(\SUPER.v)$ where $x$ is a fresh variable that is not used in $e$. 4665 Evaluation of a compound assignment $a$ of the form $\SUPER.v$ {\em ??=} $e$
eernst 2016/11/03 18:07:04 `\code{\SUPER.$v$ ??= $e$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4666 proceeds as follows:
4667
4668 Evaluate $\SUPER.v$ to an object $o$.
eernst 2016/11/03 18:07:06 `\code{\SUPER.$v$}` Ok, ok, this only changes the
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Acknowledged.
4669 If $o$ is not the null value then $a$ evaluats to $o$.
4670 Otherwise evaluate \code{\SUPER.$v$ = $e$} to an object $r$,
4671 and then $a$ evaluates to $r$.
4611 4672
4612 \LMHash{} 4673 \LMHash{}
4613 Evaluation of a compound assignment of the form $e_1?.v$ {\em ??=} $e_2$ is equ ivalent to the evaluation of the expression \code{((x) $=>$ x == \NULL{} ? \NUL L: $x.v ??= e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. 4674 Evaluation of a compound assignment $a$ of the form $e_1?.v$ {\em ??=} $e_2$
eernst 2016/11/03 18:07:04 `\code{$e_1$?.$v$ ??= $e_2$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4675 proceeds as follows:
4676
4677 Evaluate $e_1$ to an object $u$ and let \code{x} be a fresh variable bound to $u $.
eernst 2016/11/03 18:07:04 `$x$`
Lasse Reichstein Nielsen 2016/11/08 11:42:33 Done.
4678 Evaluate \code{x.$v$} to an object $o$.
eernst 2016/11/03 18:07:07 `\code{$x$.$v$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
4679 If $o$ is not the null value then $a$ evaluates to $o$.
4680 Otherwise evaluate \code{x.$v$ = $e_2$} to an object $r$,
eernst 2016/11/03 18:07:06 `\code{$x$.$v$ = $e_2$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
4681 and then $a$ evaluates to $r$.
4682
4614 % But what about C?.v ??= e 4683 % But what about C?.v ??= e
4615 4684
4616 \LMHash{} 4685 \LMHash{}
4617 A compound assignment of the form $C?.v$ {\em ??=} $e_2$ is equivalent to the e xpression $C.v$ {\em ??=} $e$. 4686 A compound assignment of the form $C?.v$ {\em ??=} $e_2$ is equivalent to the e xpression $C.v$ {\em ??=} $e$.
4618 4687
4619 \LMHash{} 4688 \LMHash{}
4620 The static type of a compound assignment of the form $v$ {\em ??=} $e$ is the le ast upper bound of the static type of $v$ and the static type of $e$. Exactly t he same static warnings that would be caused by $v = e$ are also generated in th e case of $v$ {\em ??=} $e$. 4689 The static type of a compound assignment of the form $v$ {\em ??=} $e$ is the le ast upper bound of the static type of $v$ and the static type of $e$. Exactly t he same static warnings that would be caused by $v = e$ are also generated in th e case of $v$ {\em ??=} $e$.
4621 4690
4622 4691
4623 \LMHash{} 4692 \LMHash{}
4624 The static type of a compound assignment of the form $C.v$ {\em ??=} $e$ is th e least upper bound of the static type of $C.v$ and the static type of $e$. Exa ctly the same static warnings that would be caused by $C.v = e$ are also generat ed in the case of $C.v$ {\em ??=} $e$. 4693 The static type of a compound assignment of the form $C.v$ {\em ??=} $e$ is th e least upper bound of the static type of $C.v$ and the static type of $e$. Exa ctly the same static warnings that would be caused by $C.v = e$ are also generat ed in the case of $C.v$ {\em ??=} $e$.
4625 4694
4626 \LMHash{} 4695 \LMHash{}
4627 The static type of a compound assignment of the form $e_1.v$ {\em ??=} $e_2$ is the least upper bound of the static type of $e_1.v$ and the static type of $e_2 $. Let $T$ be the static type of $e_1$ and let $z$ be a fresh variable of type $ T$. Exactly the same static warnings that would be caused by $z.v = e_2$ are als o generated in the case of $e_1.v$ {\em ??=} $e_2$. 4696 The static type of a compound assignment of the form $e_1.v$ {\em ??=} $e_2$ is the least upper bound of the static type of $e_1.v$ and the static type of $e_2 $. Let $T$ be the static type of $e_1$ and let $z$ be a fresh variable of type $ T$. Exactly the same static warnings that would be caused by $z.v = e_2$ are als o generated in the case of $e_1.v$ {\em ??=} $e_2$.
4628 4697
4629 \LMHash{} 4698 \LMHash{}
4630 The static type of a compound assignment of the form $e_1[e_2]$ {\em ??=} $e_3$ is the least upper bound of the static type of $e_1[e_2]$ and the static type of $e_3$. Exactly the same static warnings that would be caused by $e_1[e_2] = e _3$ are also generated in the case of $e_1[e_2]$ {\em ??=} $e_3$. 4699 The static type of a compound assignment of the form $e_1[e_2]$ {\em ??=} $e_3$ is the least upper bound of the static type of $e_1[e_2]$ and the static type of $e_3$. Exactly the same static warnings that would be caused by $e_1[e_2] = e _3$ are also generated in the case of $e_1[e_2]$ {\em ??=} $e_3$.
4631 4700
4632 \LMHash{} 4701 \LMHash{}
4633 The static type of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is the least upper bound of the static type of $\SUPER.v$ and the static type of $e$. Exactly the same static warnings that would be caused by $\SUPER.v = e$ ar e also generated in the case of $\SUPER.v$ {\em ??=} $e$. 4702 The static type of a compound assignment of the form $\SUPER.v$ {\em ??=} $e$ is the least upper bound of the static type of $\SUPER.v$ and the static type of $e$. Exactly the same static warnings that would be caused by $\SUPER.v = e$ ar e also generated in the case of $\SUPER.v$ {\em ??=} $e$.
4634 4703
4635 \LMHash{} 4704 \LMHash{}
4636 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 4705 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$.
eernst 2016/11/03 18:07:06 `\code{$v$ $op$= $e$}`, `\code{$v$ = $v$ $op$ $e$}
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4637 \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$. 4706
4707 Evaluation of a compound assignment $a$ of the form $e_1.v$ $op = e_2$ proceeds as follows:
eernst 2016/11/03 18:07:05 `\code{$e_1$.$v$ $op$= $e_2$}`
4708 Evaluate $e_1$ to an object $u$ and let \code{x} be a fresh variable bound to $u $.
eernst 2016/11/03 18:07:06 `$x$`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4709 Evaluate \code{x.$v$ = x.$v$ $op$ $e_2$} to an object $r$
eernst 2016/11/03 18:07:06 `\code{$x$.$v$ = $x$.$v$ $op$ $e_2$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
4710 and then $a$ evaluates to $r$.
4711
4712 Evaluation of s compound assignment $a$ of the form \code{$e_1$[$e_2$] $op$= $e _3$} proceeds as follows:
4713 Evaluate $e_1$ to an object $u$ and evaluate $e_2$ to an object $v$.
4714 Let \code{a} and \code{i} be fresh variables bound to $u$ and $v$ respectively.
eernst 2016/11/03 18:07:05 `$a$`, `$i$`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
4715 Evaluate \code{a[i] = a[i] $op$ $e_3$} to an object $r$,
eernst 2016/11/03 18:07:07 `\code{$a$[$i$] = $a$[$i$] $op$ $e_3$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
4716 and then $a$ evaluates to $r$.
4638 4717
4639 \LMHash{} 4718 \LMHash{}
4640 Evaluation of a compound assignment of the form $e_1?.v$ $op = e_2$ is equivalen t to \code{((x) $=>$ x?.v = x.v $op$ $e_2$)($e_1$)} where $x$ is a variable that is not used in $e_2$. The static type of $e_1?.v$ $op = e_2$ is the static type of $e_1.v$ $op$ $e_2$. Exactly the same static warnings that would be caused by $e_1.v$ $op = e_2$ are also generated in the case of $e_1?.v$ $op = e_2$. 4719 Evaluation of a compound assignment $a$ of the form \code{$e_1$?.$v$ $op$ = $e_2 $} proceeds as follows:
eernst 2016/11/03 18:07:03 Drop the space before `=`.
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4720
4721 Evaluate $e_1$ to an object $u$ and let \code{x} be a fresh variable bound to $u $.
eernst 2016/11/03 18:07:05 `$x$`
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
4722 Evaluate \code{x.$v$} to an object $o$.
eernst 2016/11/03 18:07:05 `\code{$x$.$v$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4723 If $o$ is the null value, then $a$ evaluates to the null value.
eernst 2016/11/03 18:07:03 Isn't the question whether $x$ (or $u$) is the nul
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Done.
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Ack, true. I was probably still thinking of ??=. R
4724 Otherwise let \code{y} be a fresh variable bound to $o$
eernst 2016/11/03 18:07:03 `$y$`
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Acknowledged.
4725 and evaluate \code{x.$v$ = t $op$ $e_2$} to an object $r$.
eernst 2016/11/03 18:07:07 `\code{$x$.$v$ = $y$ $op$ $e_2$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Acknowledged.
4726 Then $a$ evaluates to $r$.
4727
4728 The static type of $e_1?.v$ $op = e_2$ is the static type of $e_1.v$ $op$ $e_2$. Exactly the same static warnings that would be caused by $e_1.v$ $op = e_2$ are also generated in the case of $e_1?.v$ $op = e_2$.
eernst 2016/11/03 18:07:05 `\code{$e_1$?.$v$ $op$= $e_2$}`, `\code{$e_1$.$v$
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4641 4729
4642 \LMHash{} 4730 \LMHash{}
4643 A compound assignment of the form $C?.v$ $op = e_2$ is equivalent to the express ion 4731 A compound assignment of the form $C?.v$ $op = e_2$ is equivalent to the express ion
4644 $C.v$ $op = e_2$. 4732 $C.v$ $op = e_2$.
4645 4733
4646 \begin{grammar} 4734 \begin{grammar}
4647 {\bf compoundAssignmentOperator:}`*='; 4735 {\bf compoundAssignmentOperator:}`*=';
4648 `/='; 4736 `/=';
4649 `\~{}/='; 4737 `\~{}/=';
4650 `\%='; 4738 `\%=';
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4698 4786
4699 \LMHash{} 4787 \LMHash{}
4700 An {\em if-null expression}evaluates an expression and if the result is \NULL, evaluates another. 4788 An {\em if-null expression}evaluates an expression and if the result is \NULL, evaluates another.
4701 4789
4702 \begin{grammar} 4790 \begin{grammar}
4703 {\bf ifNullExpression:} 4791 {\bf ifNullExpression:}
4704 logicalOrExpression (`??' logicalOrExpression)* 4792 logicalOrExpression (`??' logicalOrExpression)*
4705 \end{grammar} 4793 \end{grammar}
4706 4794
4707 \LMHash{} 4795 \LMHash{}
4708 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$. 4796 Evaluation of an if-null expression $e$ of the form $e_1??e_2 $
eernst 2016/11/03 18:07:03 `\code{$e_1$ ?? $e_2$}`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
4797 proceeds as follows:
4798
4799 Evaluate $e_1$ to an object $o$.
4800 If $o$ is not the null value, then $e$ evaluates to $o$.
4801 Otherwise evaluate $e_2$ to an object $r$,
4802 and then $e$ evaluates to $r$.
4803
4804 The static type of $e$ is least upper bound (\ref{leastUpperBounds}) of the stat ic type of $e_1$ and the static type of $e_2$.
4709 4805
4710 4806
4711 \subsection{ Logical Boolean Expressions} 4807 \subsection{ Logical Boolean Expressions}
4712 \LMLabel{logicalBooleanExpressions} 4808 \LMLabel{logicalBooleanExpressions}
4713 4809
4714 \LMHash{} 4810 \LMHash{}
4715 The logical boolean expressions combine boolean objects using the boolean conjun ction and disjunction operators. 4811 The logical boolean expressions combine boolean objects using the boolean conjun ction and disjunction operators.
4716 4812
4717 \begin{grammar} 4813 \begin{grammar}
4718 {\bf logicalOrExpression:} 4814 {\bf logicalOrExpression:}
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
5069 {\bf incrementOperator:}`++'; 5165 {\bf incrementOperator:}`++';
5070 `-{}-' 5166 `-{}-'
5071 . 5167 .
5072 5168
5073 \end{grammar} 5169 \end{grammar}
5074 5170
5075 \LMHash{} 5171 \LMHash{}
5076 A {\em postfix expression} is either a primary expression, a function, method o r getter invocation, or an invocation of a postfix operator on an expression $e$ . 5172 A {\em postfix expression} is either a primary expression, a function, method o r getter invocation, or an invocation of a postfix operator on an expression $e$ .
5077 5173
5078 \LMHash{} 5174 \LMHash{}
5079 Execution of a postfix expression of the form \code{$v$++}, where $v$ is an iden tifier, is equivalent to executing \code{()\{\VAR{} r = $v$; $v$ = r + 1; \RETUR N{} r\}()}. 5175 Evaluation of a postfix expression $e$ of the form \code{$v$++}, where $v$ is an identifier, proceeds as follows:
5176
5177 Evaluate $v$ to an object $r$ and let \code{t} be a fresh variable bound to $r$.
eernst 2016/11/03 18:07:05 $t$
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
5178 Evaluate \code{$v$ = y + 1}.
eernst 2016/11/03 18:07:04 `\code{$v$ = $y$ + 1}`
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Done.
5179 Then $e$ evaluates to $r$.
5080 5180
5081 \LMHash{} 5181 \LMHash{}
5082 The static type of such an expression is the static type of $v$. 5182 The static type of such an expression is the static type of $v$.
5083 5183
5084 5184
5085 \rationale{The above ensures that if $v$ is a field, the getter gets called exac tly once. Likewise in the cases below. 5185 \rationale{The above ensures that if $v$ is a field, the getter gets called exac tly once. Likewise in the cases below.
5086 } 5186 }
5087 5187
5088 \LMHash{} 5188 \LMHash{}
5089 Execution of a postfix expression of the form \code{$C.v$ ++} is equivalent to e xecuting 5189 Evaluation of a postfix expression $e$ of the form \code{$C.v$ ++}
eernst 2016/11/03 18:07:03 Drop the space before `++`.
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Done.
5190 proceeds as follows:
5090 5191
5091 \code{()\{\VAR{} r = $C.v$; $C.v$ = r + 1; \RETURN{} r\}()}. 5192 Evaluate $C.v$ to a value $r$ and let \code{y} be a fresh variable bound to $r$.
eernst 2016/11/03 18:07:05 `$y$`
5193 Evaluate \code{$C.v$ = y + 1}.
eernst 2016/11/03 18:07:04 `\code{$C$.$v$ = $y$ + 1}`
5194 Then $e$ evaluates to $r$.
5092 5195
5093 \LMHash{} 5196 \LMHash{}
5094 The static type of such an expression is the static type of $C.v$. 5197 The static type of such an expression is the static type of $C.v$.
5095 5198
5096 5199
5097 \LMHash{} 5200 \LMHash{}
5098 Execution of a postfix expression of the form \code{$e_1.v$++} is equivalent to executing 5201 Evaluating of a postfix expression $e$ of the form \code{$e_1.v$++}
5202 proceeds as follows:
5099 5203
5100 \code{(x)\{\VAR{} r = x.v; x.v = r + 1; \RETURN{} r\}($e_1$)}. 5204 Evaluate $e_1$ to an object $u$ and let \code{x} be a fresh variable bound to $u $.
eernst 2016/11/03 18:07:05 `$x$`
5205 Evaluate \code{x.$v$} to a value $r$ and let \code{y} be a fresh variable bound to $r$.
eernst 2016/11/03 18:07:07 `\code{$x$.$v$}`, `$y$`.
5206 Evaluate \code{x.$v$ = y + 1}.
eernst 2016/11/03 18:07:04 `\code{$x$.$v$ = $y$ + 1}`
5207 Then $e$ evaluates to $r$.
5101 5208
5102 \LMHash{} 5209 \LMHash{}
5103 The static type of such an expression is the static type of $e_1.v$. 5210 The static type of such an expression is the static type of $e_1.v$.
5104 5211
5105 5212
5106 \LMHash{} 5213 \LMHash{}
5107 Execution of a postfix expression of the form \code{$e_1[e_2]$++}, is equivalen t to executing 5214 Evaluation of a postfix expression $e$ of the form \code{$e_1[e_2]$++}
eernst 2016/11/03 18:07:07 `\code{$e_1$[$e_2$]++}`
5215 proceeds as follows:
5108 5216
5109 \code{(a, i)\{\VAR{} r = a[i]; a[i] = r + 1; \RETURN{} r\}($e_1$, $e_2$)}. 5217 Evaluate $e_1$ to an object $u$ and $e_2$ to an object $v$.
5218 Let \code{a} and \code{i} be fresh variables bound to $u$ and $v$ respectively.
eernst 2016/11/03 18:07:06 `$a$`, `$i$`
5219 Evaluate \code{a[i]} to an object $r$ and let $y$ be a fresh variable bound to $ r$.
eernst 2016/11/03 18:07:02 `\code{$a$[$i]}`
5220 Evaluate \code{a[i] = y + 1}.
eernst 2016/11/03 18:07:03 `\code{$a$[$i$] = $y$ + 1}`
5221 Then $e$ evaluates to $r$.
5110 5222
5111 \LMHash{} 5223 \LMHash{}
5112 The static type of such an expression is the static type of $e_1[e_2]$. 5224 The static type of such an expression is the static type of $e_1[e_2]$.
5113 5225
5114 5226
5115 \LMHash{} 5227 \LMHash{}
5116 Execution of a postfix expression of the form \code{$v$-{}-}, where $v$ is an id entifier, is equivalent to executing 5228 Evaluation of a postfix expression $e$ of the form \code{$v$-{}-}, where $v$ is an identifier, proceeds as follows:
5117 5229
5118 \code{()\{\VAR{} r = $v$; $v$ = r - 1; \RETURN{} r\}()}. 5230 Evaluate the expression $v$ to an object $r$ and let \code{y} be a fresh variabl e bound to $r$.
eernst 2016/11/03 18:07:05 `$y$`
5231 Evaluate \code{$v$ = y - 1}.
eernst 2016/11/03 18:07:02 `\code{$v$ = $y$ - 1}`
5232 Then $e$ evaluates to $r$.
5119 5233
5120 \LMHash{} 5234 \LMHash{}
5121 The static type of such an expression is the static type of $v$. 5235 The static type of such an expression is the static type of $v$.
5122 5236
5123 5237
5124 \LMHash{} 5238 \LMHash{}
5125 Execution of a postfix expression of the form \code{$C.v$-{}-} is equivalent to executing 5239 Evaluation of a postfix expression $e$ of the form \code{$C.v$-{}-}
5240 proceeds as follows:
5126 5241
5127 \code{()\{\VAR{} r = $C.v$; $C.v$ = r - 1; \RETURN{} r\}()}. 5242 Evaluate $C.v$ to a value $r$ and let \code{y} be a fresh variable bound to $r$.
eernst 2016/11/03 18:07:05 `$y$`
5243 Evaluate \code{$C.v$ = y - 1}.
eernst 2016/11/03 18:07:07 `\code{$C$.$v$ = $y$ - 1}`
5244 Then $e$ evaluates to $r$.
5128 5245
5129 \LMHash{} 5246 \LMHash{}
5130 The static type of such an expression is the static type of $C.v$. 5247 The static type of such an expression is the static type of $C.v$.
5131 5248
5132 5249
5133 \LMHash{} 5250 \LMHash{}
5134 Execution of a postfix expression of the form \code{$e_1.v$-{}-} is equivalent t o executing 5251 Evaluation of a postfix expression of the form \code{$e_1.v$-{}-}
eernst 2016/11/03 18:07:06 `\code{$e_1$.$v$-{}-}`
5252 proceeds as follows:
5135 5253
5136 \code{(x)\{\VAR{} r = x.v; x.v = r - 1; \RETURN{} r\}($e_1$)}. 5254 Evaluate $e_1$ to an object $u$ and let \code{x} be a fresh variable bound to $u $.
eernst 2016/11/03 18:07:06 `$x$`
5255 Evaluate \code{x.$v$} to a value $r$ and let \code{y} be a fresh variable bound to $r$.
eernst 2016/11/03 18:07:05 `\code{$x$.$v$}`, `$y$`
5256 Evaluate \code{x.$v$ = y - 1}.
eernst 2016/11/03 18:07:03 `\code{$x$.$v$ = $y$ -1}`
5257 Then $e$ evaluates to $r$.
5258
5137 5259
5138 \LMHash{} 5260 \LMHash{}
5139 The static type of such an expression is the static type of $e_1.v$. 5261 The static type of such an expression is the static type of $e_1.v$.
5140 5262
5141 5263
5142 \LMHash{} 5264 \LMHash{}
5143 Execution of a postfix expression of the form \code{$e_1[e_2]$-{}-}, is equival ent to executing 5265 Evaluation of a postfix expression $e$ of the form \code{$e_1[e_2]$-{}-}
eernst 2016/11/03 18:07:03 `\code{$e_1$[$e_2$]-{}-}`
5266 proceeds as follows:
5144 5267
5145 \code{(a, i)\{\VAR{} r = a[i]; a[i] = r - 1; \RETURN{} r\}($e_1$, $e_2$)}. 5268 Evaluate $e_1$ to an object $u$ and $e_2$ to an object $v$.
5269 Let \code{a} and \code{i} be fresh variables bound to $u$ and $v$ respectively.
eernst 2016/11/03 18:07:03 `$a$`, `$i$`
5270 Evaluate \code{a[i]} to an object $r$ and let $y$ be a fresh variable bound to $ r$.
eernst 2016/11/03 18:07:06 `\code{$a$[$i$]}`
5271 Evaluate \code{a[i] = y - 1}.
eernst 2016/11/03 18:07:05 `\code{$a$[$i$] = $y$ - 1}`
5272 Then $e$ evaluates to $r$.
5146 5273
5147 \LMHash{} 5274 \LMHash{}
5148 The static type of such an expression is the static type of $e_1[e_2]$. 5275 The static type of such an expression is the static type of $e_1[e_2]$.
5149 5276
5150 \LMHash{} 5277 \LMHash{}
5151 Execution of a postfix expression of the form \code{$e_1?.v$++} is equivalent to executing 5278 Evaluation of a postfix expression $e$ of the form \code{$e_1?.v$++}
eernst 2016/11/03 18:07:06 `\code{$e_1$?.$v$++}`
5279 where $e_1$ is not a type literal, proceeds as follows:
5152 5280
5153 \code{((x) =$>$ x == \NULL? \NULL : x.v++)($e_1$)} 5281 Evaluate $e_1$ to an object $u$ and let \code{x} be a fresh variable bound to $u $.
eernst 2016/11/03 18:07:04 `$x$`
Lasse Reichstein Nielsen 2016/11/08 11:42:36 All the above comments: done.
5154 unless $e_1$ is a type literal, in which case it is equivalent to \code{$e_1.v$+ +} 5282 Evaluate \code{u.$v$} to an object $o$.
eernst 2016/11/03 18:07:04 `\code{$x$.$v$}` (if we can evaluate $u$.$v$ then
Lasse Reichstein Nielsen 2016/11/08 11:42:36 ack, same bug. Fixed.
5155 . 5283 If $o$ is the null value, then $e$ evaluates to the null value.
eernst 2016/11/03 18:07:07 This test may then be moved up before computing $x
Lasse Reichstein Nielsen 2016/11/08 11:42:36 Acknowledged.
5284 Otherwise let $y$ be a fresh variable bound to $o$
5285 and evaluate \code{u.$v$ = y + 1}.
eernst 2016/11/03 18:07:05 `\code{$x$.$v$ = $y$ + 1}`
Lasse Reichstein Nielsen 2016/11/08 11:42:35 Rewritten to just evaluate \code{$x$.$v$++}.
5286 Then $e$ evaluates to $o$.
5287
5288 If $e_1$ is a type literal, $e$ is equivalent to \code{$e_1$.$v$++}.
eernst 2016/11/03 18:07:06 This also motivates a test on $u$ rather than $o$:
5156 5289
5157 \LMHash{} 5290 \LMHash{}
5158 The static type of such an expression is the static type of $e_1.v$. 5291 The static type of such an expression is the static type of $e_1.v$.
5159 5292
5160 \LMHash{} 5293 \LMHash{}
5161 Execution of a postfix expression of the form \code{$e_1?.v$-{}-} is equivalent to executing 5294 Evaluation of a postfix expression $e$ of the form \code{$e_1?.v$-{}-}
eernst 2016/11/03 18:07:04 `\code{$e_1$?.$v$-{}-}`
Lasse Reichstein Nielsen 2016/11/08 11:42:34 -- case fixed the same way as ++.
5295 where $e_1$ is not a type literal, proceeds as follows:
5162 5296
5163 \code{((x) =$>$ x == \NULL? \NULL : x.v-{}-)($e_1$)} 5297 Evaluate $e_1$ to an object $u$ and let \code{x} be a fresh variable bound to $u $.
eernst 2016/11/03 18:07:04 `$x$`
5164 unless $e_1$ is a type literal, in which case it is equivalent to \code{$e_1.v$- {}-} 5298 Evaluate \code{u.$v$} to an object $o$.
eernst 2016/11/03 18:07:03 `\code{$x$.$v$}`
5165 . 5299 If $o$ is the null value, then $e$ evaluates to the null value.
5300 Otherwise let $y$ be a fresh variable bound to $o$
5301 and evaluate \code{u.$v$ = y - 1}.
eernst 2016/11/03 18:07:04 `\code{$x$.$v$ = $y$ - 1}`
5302 Then $e$ evaluates to $o$.
5303
5304 If $e_1$ is a type literal, $e$ is equivalent to \code{$e_1$.$v$-{}-}.
5166 5305
5167 \LMHash{} 5306 \LMHash{}
5168 The static type of such an expression is the static type of $e_1.v$. 5307 The static type of such an expression is the static type of $e_1.v$.
5169 5308
5170 5309
5171 \subsection{ Assignable Expressions} 5310 \subsection{ Assignable Expressions}
5172 \LMLabel{assignableExpressions} 5311 \LMLabel{assignableExpressions}
5173 5312
5174 \LMHash{} 5313 \LMHash{}
5175 Assignable expressions are expressions that can appear on the left hand side of an assignment. 5314 Assignable expressions are expressions that can appear on the left hand side of an assignment.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
5426 \LMHash{} 5565 \LMHash{}
5427 Evaluation of the cast expression \code{$e$ \AS{} $T$} proceeds as follows: 5566 Evaluation of the cast expression \code{$e$ \AS{} $T$} proceeds as follows:
5428 5567
5429 \LMHash{} 5568 \LMHash{}
5430 The expression $e$ is evaluated to a value $v$. Then, if $T$ is a malformed or d eferred type (\ref{staticTypes}), a dynamic error occurs. Otherwise, if the inte rface of the class of $v$ is a subtype of $T$, the cast expression evaluates to $v$. Otherwise, if $v$ is \NULL{}, the cast expression evaluates to $v$. 5569 The expression $e$ is evaluated to a value $v$. Then, if $T$ is a malformed or d eferred type (\ref{staticTypes}), a dynamic error occurs. Otherwise, if the inte rface of the class of $v$ is a subtype of $T$, the cast expression evaluates to $v$. Otherwise, if $v$ is \NULL{}, the cast expression evaluates to $v$.
5431 In all other cases, a \code{CastError} is thrown. 5570 In all other cases, a \code{CastError} is thrown.
5432 5571
5433 \LMHash{} 5572 \LMHash{}
5434 The static type of a cast expression \code{$e$ \AS{} $T$} is $T$. 5573 The static type of a cast expression \code{$e$ \AS{} $T$} is $T$.
5435 5574
5575 \subsection{ Let}
5576 \LMLabel{let}
5577
5578 \LMHash{}
5579 The {\em let expression} evaluates two expressions and allows the second express ion to refer to the value of the first.
5580
5581 The let expression is not expressible in the concrete grammar of the Dart langua ge. It cannot be used in a Dart program.
5582 It is instead a synthetic construct used internally
5583 in the language specification for rewriting other expressions.
5584
5585 \begin{grammar}
5586 {\bf letExpression: }
5587 `let' $identifier$ `=' $expression$ `in' $expression$;
5588 \end{grammar}
5589
5590 A let expression $e$ on the form \code{let $v$ = $e_1$ in $e_2$}
5591 introduces a new scope, which is nested in the lexically enclosing scope in whic h the let expression is evaluated.
5592 The new scope introduces a final local variable $v$, and it covers only $e_2$,
5593 not $e_1$.
5594
5595 The static type of $v$ is the same as the static type of $e_1$.
5596
5597 Evaluation of $e$ proceeds as follows:
5598
5599 First $e_1$ is evaluated to a value $o_1$.
5600 Then $v$ is bound to $o_1$ in the new scope,
5601 and $e_2$ is evaluated to a value $o_2$ in this scope.
5602 The evaluation of $e$ produces the value $o_2$.
5603
5604 \commentary{
5605 The syntax for the let expression is abstract, so it doesn't matter that
5606 \code{let} is not a reserved word.
5607 }
5608
5609 \commentary{
5610 Before introducing asynchronous functions to the Dart language, an expression on the form \code{((v) => e2)(e1)} would be equivalent to a let expression,
5611 and that was the rewrite used for, e.g., the logical and operator
5612 (\ref{logicalBooleanExpressions}).
5613 In an asynchronous function that rewrite is no longer correct because it moves \ code{e2} into a non-synchronous function. If \code{e2} contains an await stateme nt, the result will be an invalid expression.
5614 }
eernst 2016/11/03 18:07:07 Wouldn't this whole section be unused at this poin
Lasse Reichstein Nielsen 2016/11/08 11:42:34 Absolutely. I thought I removed it. One undo too m
5436 5615
5437 \section{Statements} 5616 \section{Statements}
5438 \LMLabel{statements} 5617 \LMLabel{statements}
5439 5618
5440 \begin{grammar} 5619 \begin{grammar}
5441 {\bf statements:} 5620 {\bf statements:}
5442 statement* 5621 statement*
5443 . 5622 .
5444 5623
5445 5624
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5562 \end{grammar} 5741 \end{grammar}
5563 5742
5564 \LMHash{} 5743 \LMHash{}
5565 A function declaration statement of one of the forms $id$ $signature$ $\{ statem ents \}$ or $T$ $id$ $signature$ $\{ statements \}$ causes a new function named $id$ to be added to the innermost enclosing scope. It is a compile-time error to reference a local function before its declaration. 5744 A function declaration statement of one of the forms $id$ $signature$ $\{ statem ents \}$ or $T$ $id$ $signature$ $\{ statements \}$ causes a new function named $id$ to be added to the innermost enclosing scope. It is a compile-time error to reference a local function before its declaration.
5566 5745
5567 5746
5568 \commentary{ This implies that local functions can be directly recursive, but no t mutually recursive. Consider these examples: 5747 \commentary{ This implies that local functions can be directly recursive, but no t mutually recursive. Consider these examples:
5569 } 5748 }
5570 5749
5571 \begin{dartCode} 5750 \begin{dartCode}
5572 f(x) =$>$ x++; // a top level function 5751 f(x) $=>$ x++; // a top level function
eernst 2016/11/03 18:07:05 Just keep `=$>$`
Lasse Reichstein Nielsen 2016/11/08 11:42:36 OK, but not consistent with the following lines. W
5573 top() \{ // another top level function 5752 top() \{ // another top level function
5574 f(3); // illegal 5753 f(3); // illegal
5575 f(x) $=>$ x $>$ 0? x*f(x-1): 1; // recursion is legal 5754 f(x) $=>$ x $>$ 0? x*f(x-1): 1; // recursion is legal
5576 g1(x) $=>$ h(x, 1); // error: h is not declared yet 5755 g1(x) $=>$ h(x, 1); // error: h is not declared yet
5577 h(x, n) $=>$ x $>$ 1? h(x-1, n*x): n; // again, recursion is fine 5756 h(x, n) $=>$ x $>$ 1? h(x-1, n*x): n; // again, recursion is fine
5578 g2(x) $=>$ h(x, 1); // legal 5757 g2(x) $=>$ h(x, 1); // legal
5579 5758
5580 p1(x) $=>$ q(x,x); // illegal 5759 p1(x) $=>$ q(x,x); // illegal
5581 q1(a, b)$ =>$ a $>$ 0 ? p1(a-1): b; // fine 5760 q1(a, b)$ =>$ a $>$ 0 ? p1(a-1): b; // fine
5582 5761
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
6155 \begin{itemize} 6334 \begin{itemize}
6156 \item 6335 \item
6157 if there is a dynamically enclosing error handler $g$ defined by a \FINALLY{} c lause in $m$, control is transferred to $g$. 6336 if there is a dynamically enclosing error handler $g$ defined by a \FINALLY{} c lause in $m$, control is transferred to $g$.
6158 \item 6337 \item
6159 Otherwise $m$ terminates. 6338 Otherwise $m$ terminates.
6160 \end{itemize} 6339 \end{itemize}
6161 6340
6162 Otherwise, execution resumes at the end of the try statement. 6341 Otherwise, execution resumes at the end of the try statement.
6163 6342
6164 \LMHash{} 6343 \LMHash{}
6165 Execution of an \ON{}-\CATCH{} clause \code{\ON{} $T$ \CATCH{} ($p_1$, $p_2$)} $ s$ of a try statement $t$ proceeds as follows: The statement $s$ is executed in the dynamic scope of the exception handler defined by the finally clause of $t$. Then, the current exception and active stack trace both become undefined. 6344 Execution of an \ON{}-\CATCH{} clause \code{\ON{} $T$ \CATCH{} ($p_1$, $p_2$)} $ s$ of a try statement $t$ proceeds as follows:
6345 The statement $s$ is executed in the dynamic scope of the exception handler defi ned by the finally clause of $t$. Then, the current exception and active stack t race both become undefined.
6166 6346
6167 \LMHash{} 6347 \LMHash{}
6168 Execution of a \FINALLY{} clause \FINALLY{} $s$ of a try statement proceeds as f ollows: 6348 Execution of a \FINALLY{} clause \FINALLY{} $s$ of a try statement proceeds as f ollows:
6169 6349
6170 \LMHash{} 6350 \LMHash{}
6171 Let $x$ be the current exception and let $t$ be the active stack trace. Then the current exception and the active stack trace both become undefined. The stateme nt $s$ is executed. Then, if $x$ is defined, it is rethrown as if by a rethrow statement (\ref{rethrow}) enclosed in a \CATCH{} clause of the form \code{\CATCH {} ($v_x$, $v_t$)} where $v_x$ and $v_t$ are fresh variables bound to $x$ and $t $ respectively. 6351 Let $x$ be the current exception and let $t$ be the active stack trace. Then the current exception and the active stack trace both become undefined. The stateme nt $s$ is executed. Then, if $x$ is defined, it is rethrown as if by a rethrow statement (\ref{rethrow}) enclosed in a \CATCH{} clause of the form \code{\CATCH {} ($v_x$, $v_t$)} where $v_x$ and $v_t$ are fresh variables bound to $x$ and $t $ respectively.
6172 6352
6173 6353
6174 \LMHash{} 6354 \LMHash{}
6175 Execution of a try statement of the form \code{\TRY{} $s_1$ $on-catch_1 \ldots o n-catch_n$ \FINALLY{} $s_f$;} proceeds as follows: 6355 Execution of a try statement of the form \code{\TRY{} $s_1$ $on-catch_1 \ldots o n-catch_n$ \FINALLY{} $s_f$;} proceeds as follows:
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after
7912 8092
7913 The invariant that each normative paragraph is associated with a line 8093 The invariant that each normative paragraph is associated with a line
7914 containing the text \LMHash{} should be maintained. Extra occurrences 8094 containing the text \LMHash{} should be maintained. Extra occurrences
7915 of \LMHash{} can be added if needed, e.g., in order to make 8095 of \LMHash{} can be added if needed, e.g., in order to make
7916 individual \item{}s in itemized lists addressable. Each \LM.. command 8096 individual \item{}s in itemized lists addressable. Each \LM.. command
7917 must occur on a separate line. \LMHash{} must occur immediately 8097 must occur on a separate line. \LMHash{} must occur immediately
7918 before the associated paragraph, and \LMLabel must occur immediately 8098 before the associated paragraph, and \LMLabel must occur immediately
7919 after the associated \section{}, \subsection{} etc. 8099 after the associated \section{}, \subsection{} etc.
7920 8100
7921 ---------------------------------------------------------------------- 8101 ----------------------------------------------------------------------
OLDNEW
« docs/language/dart.sty ('K') | « docs/language/dart.sty ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698