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

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

Issue 1183493005: Added type rules for e++ and friends (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | 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 {\large Version 1.10}} 10 {\large Version 1.10}}
(...skipping 3852 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 \end{code} 3863 \end{code}
3864 3864
3865 \commentary{Notice that the wording carefully avoids re-evaluating the receiver $o$ and the arguments $a_i$. } 3865 \commentary{Notice that the wording carefully avoids re-evaluating the receiver $o$ and the arguments $a_i$. }
3866 3866
3867 \LMHash{} 3867 \LMHash{}
3868 Let $T$ be the static type of $o$. It is a static type warning if $T$ does not have an accessible (\ref{privacy}) instance member named $m$ unless either: 3868 Let $T$ be the static type of $o$. It is a static type warning if $T$ does not have an accessible (\ref{privacy}) instance member named $m$ unless either:
3869 \begin{itemize} 3869 \begin{itemize}
3870 \item 3870 \item
3871 $T$ or a superinterface of $T$ is annotated with an annotation denoting a consta nt identical to the constant \code{@proxy} defined in \code{dart:core}. Or 3871 $T$ or a superinterface of $T$ is annotated with an annotation denoting a consta nt identical to the constant \code{@proxy} defined in \code{dart:core}. Or
3872 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static getter named $m$. 3872 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static getter named $m$.
3873 \item $T$ is \code{Function} and $m$ is \CALL. \rationale {The type \code{Functi on} is treated as if it has a \code{call} method for any possible signature of \ CALL. The expectation is that any concrete subclass of \code{Function} will impl ement \CALL. Note that a warning will be issue if this is not the case. Furtherm ore, any use of \CALL on a subclass of \code{Function} that fails to implement \ CALL{} will also provoke a a warning, as this exemption is limited to type \code {Function}, and does not apply to its subtypes.
3874 }
3873 \end{itemize} 3875 \end{itemize}
3874 3876
3875 \LMHash{} 3877 \LMHash{}
3876 If $T.m$ exists, it is a static type warning if the type $F$ of $T.m$ may not b e assigned to a function type. If $T.m$ does not exist, or if $F$ is not a funct ion type, the static type of $i$ is \DYNAMIC{}; otherwise the static type of $i$ is the declared return type of $F$. 3878 If $T.m$ exists, it is a static type warning if the type $F$ of $T.m$ may not b e assigned to a function type. If $T.m$ does not exist, or if $F$ is not a funct ion type, the static type of $i$ is \DYNAMIC{}; otherwise the static type of $i$ is the declared return type of $F$.
3877 3879
3878 \LMHash{} 3880 \LMHash{}
3879 It is a compile-time error to invoke any of the methods of class \cd{Object} on a prefix object (\ref{imports}) or on a constant type literal that is immediate ly followed by the token `.'. 3881 It is a compile-time error to invoke any of the methods of class \cd{Object} on a prefix object (\ref{imports}) or on a constant type literal that is immediate ly followed by the token `.'.
3880 3882
3881 3883
3882 \subsubsection{Cascaded Invocations} 3884 \subsubsection{Cascaded Invocations}
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
4151 4153
4152 \commentary{ 4154 \commentary{
4153 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. 4155 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.
4154 } 4156 }
4155 4157
4156 \LMHash{} 4158 \LMHash{}
4157 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: 4159 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:
4158 \begin{itemize} 4160 \begin{itemize}
4159 \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 4161 \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
4160 \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$. 4162 \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$.
4163 \item $T$ is \code{Function} and $m$ is \CALL.
4161 \end{itemize} 4164 \end{itemize}
4162 4165
4163 The static type of $i$ is: 4166 The static type of $i$ is:
4164 \begin{itemize} 4167 \begin{itemize}
4165 \item The static type of function $T.m$, if $T$ has an accessible instance membe r named $m$. 4168 \item The static type of function $T.m$, if $T$ has an accessible instance membe r named $m$.
4166 \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$. 4169 \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$.
4170 \item \code{Function} if $T$ is \code{Function} and $m$ is \CALL.
4167 \item The type \DYNAMIC{} otherwise. 4171 \item The type \DYNAMIC{} otherwise.
4168 \end{itemize} 4172 \end{itemize}
4169 4173
4170 \subsubsection{Named Constructor Extraction} 4174 \subsubsection{Named Constructor Extraction}
4171 \LMLabel{namedConstructorExtraction} 4175 \LMLabel{namedConstructorExtraction}
4172 4176
4173 \LMHash{} 4177 \LMHash{}
4174 Evaluation of a property extraction $i$ of the form \NEW{} $T\#m$ proceeds as fo llows: 4178 Evaluation of a property extraction $i$ of the form \NEW{} $T\#m$ proceeds as fo llows:
4175 4179
4176 \LMHash{} 4180 \LMHash{}
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
5003 {\bf incrementOperator:}`++'; 5007 {\bf incrementOperator:}`++';
5004 `-{}-' 5008 `-{}-'
5005 . 5009 .
5006 5010
5007 \end{grammar} 5011 \end{grammar}
5008 5012
5009 \LMHash{} 5013 \LMHash{}
5010 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$ . 5014 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$ .
5011 5015
5012 \LMHash{} 5016 \LMHash{}
5013 A postfix expression of the form \code{$v$++}, where $v$ is an identifier, is eq uivalent to \code{()\{\VAR{} r = $v$; $v$ = r + 1; \RETURN{} r\}()}. 5017 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\}()}.
5018
5019 \LMHash{}
5020 The static type of such an expression is the static type of $v$.
5021
5014 5022
5015 \rationale{The above ensures that if $v$ is a field, the getter gets called exac tly once. Likewise in the cases below. 5023 \rationale{The above ensures that if $v$ is a field, the getter gets called exac tly once. Likewise in the cases below.
5016 } 5024 }
5017 5025
5018 \LMHash{} 5026 \LMHash{}
5019 A postfix expression of the form \code{$C.v$ ++} is equivalent to 5027 Execution of a postfix expression of the form \code{$C.v$ ++} is equivalent to e xecuting
5020 5028
5021 \code{()\{\VAR{} r = $C.v$; $C.v$ = r + 1; \RETURN{} r\}()}. 5029 \code{()\{\VAR{} r = $C.v$; $C.v$ = r + 1; \RETURN{} r\}()}.
5022 5030
5023 \LMHash{} 5031 \LMHash{}
5024 A postfix expression of the form \code{$e_1.v$++} is equivalent to 5032 The static type of such an expression is the static type of $C.v$.
5033
5034
5035 \LMHash{}
5036 Execution of a postfix expression of the form \code{$e_1.v$++} is equivalent to executing
5025 5037
5026 \code{(x)\{\VAR{} r = x.v; x.v = r + 1; \RETURN{} r\}($e_1$)}. 5038 \code{(x)\{\VAR{} r = x.v; x.v = r + 1; \RETURN{} r\}($e_1$)}.
5027 5039
5028 \LMHash{} 5040 \LMHash{}
5029 A postfix expression of the form \code{$e_1[e_2]$++}, is equivalent to 5041 The static type of such an expression is the static type of $e_1.v$.
5042
5043
5044 \LMHash{}
5045 Execution of a postfix expression of the form \code{$e_1[e_2]$++}, is equivalen t to executing
5030 5046
5031 \code{(a, i)\{\VAR{} r = a[i]; a[i] = r + 1; \RETURN{} r\}($e_1$, $e_2$)}. 5047 \code{(a, i)\{\VAR{} r = a[i]; a[i] = r + 1; \RETURN{} r\}($e_1$, $e_2$)}.
5032 5048
5033 \LMHash{} 5049 \LMHash{}
5034 A postfix expression of the form \code{$v$-{}-}, where $v$ is an identifier, is equivalent to 5050 The static type of such an expression is the static type of $e_1[e_2]$.
5051
5052
5053 \LMHash{}
5054 Execution of a postfix expression of the form \code{$v$-{}-}, where $v$ is an id entifier, is equivalent to executing
5035 5055
5036 \code{()\{\VAR{} r = $v$; $v$ = r - 1; \RETURN{} r\}()}. 5056 \code{()\{\VAR{} r = $v$; $v$ = r - 1; \RETURN{} r\}()}.
5037 5057
5038 \LMHash{} 5058 \LMHash{}
5039 A postfix expression of the form \code{$C.v$-{}-} is equivalent to 5059 The static type of such an expression is the static type of $v$.
5060
5061
5062 \LMHash{}
5063 Execution of a postfix expression of the form \code{$C.v$-{}-} is equivalent to executing
5040 5064
5041 \code{()\{\VAR{} r = $C.v$; $C.v$ = r - 1; \RETURN{} r\}()}. 5065 \code{()\{\VAR{} r = $C.v$; $C.v$ = r - 1; \RETURN{} r\}()}.
5042 5066
5043 \LMHash{} 5067 \LMHash{}
5044 A postfix expression of the form \code{$e_1.v$-{}-} is equivalent to 5068 The static type of such an expression is the static type of $C.v$.
5069
5070
5071 \LMHash{}
5072 Execution of a postfix expression of the form \code{$e_1.v$-{}-} is equivalent t o executing
5045 5073
5046 \code{(x)\{\VAR{} r = x.v; x.v = r - 1; \RETURN{} r\}($e_1$)}. 5074 \code{(x)\{\VAR{} r = x.v; x.v = r - 1; \RETURN{} r\}($e_1$)}.
5047 5075
5048 \LMHash{} 5076 \LMHash{}
5049 A postfix expression of the form \code{$e_1[e_2]$-{}-}, is equivalent to 5077 The static type of such an expression is the static type of $e_1.v$.
5078
5079
5080 \LMHash{}
5081 Execution of a postfix expression of the form \code{$e_1[e_2]$-{}-}, is equival ent to executing
5050 5082
5051 \code{(a, i)\{\VAR{} r = a[i]; a[i] = r - 1; \RETURN{} r\}($e_1$, $e_2$)}. 5083 \code{(a, i)\{\VAR{} r = a[i]; a[i] = r - 1; \RETURN{} r\}($e_1$, $e_2$)}.
5052 5084
5053 \LMHash{} 5085 \LMHash{}
5054 A postfix expression of the form \code{$e_1?.v$++} is equivalent to 5086 The static type of such an expression is the static type of $e_1[e_2]$.
5087
5088 \LMHash{}
5089 Execution of a postfix expression of the form \code{$e_1?.v$++} is equivalent to executing
5055 5090
5056 \code{((x) =$>$ x == \NULL? \NULL : x.v++)($e_1$)}. 5091 \code{((x) =$>$ x == \NULL? \NULL : x.v++)($e_1$)}.
5057 5092
5058 \LMHash{} 5093 \LMHash{}
5059 A postfix expression of the form \code{$e_1?.v$-{}-} is equivalent to 5094 The static type of such an expression is the static type of $e_1.v$.
5095
5096 \LMHash{}
5097 Execution of a postfix expression of the form \code{$e_1?.v$-{}-} is equivalent to executing
5060 5098
5061 \code{((x) =$>$ x == \NULL? \NULL : x.v-{}-)($e_1$)}. 5099 \code{((x) =$>$ x == \NULL? \NULL : x.v-{}-)($e_1$)}.
5062 5100
5101 \LMHash{}
5102 The static type of such an expression is the static type of $e_1.v$.
5103
5063 5104
5064 \subsection{ Assignable Expressions} 5105 \subsection{ Assignable Expressions}
5065 \LMLabel{assignableExpressions} 5106 \LMLabel{assignableExpressions}
5066 5107
5067 \LMHash{} 5108 \LMHash{}
5068 Assignable expressions are expressions that can appear on the left hand side of an assignment. 5109 Assignable expressions are expressions that can appear on the left hand side of an assignment.
5069 This section describes how to evaluate these expressions when they do not consti tute the complete left hand side of an assignment. 5110 This section describes how to evaluate these expressions when they do not consti tute the complete left hand side of an assignment.
5070 5111
5071 \rationale{ 5112 \rationale{
5072 Of course, if assignable expressions always appeared {\em as} the left hand side , one would have no need for their value, and the rules for evaluating them woul d be unnecessary. However, assignable expressions can be subexpressions of othe r expressions and therefore must be evaluated. 5113 Of course, if assignable expressions always appeared {\em as} the left hand side , one would have no need for their value, and the rules for evaluating them woul d be unnecessary. However, assignable expressions can be subexpressions of othe r expressions and therefore must be evaluated.
(...skipping 2731 matching lines...) Expand 10 before | Expand all | Expand 10 after
7804 7845
7805 The invariant that each normative paragraph is associated with a line 7846 The invariant that each normative paragraph is associated with a line
7806 containing the text \LMHash{} should be maintained. Extra occurrences 7847 containing the text \LMHash{} should be maintained. Extra occurrences
7807 of \LMHash{} can be added if needed, e.g., in order to make 7848 of \LMHash{} can be added if needed, e.g., in order to make
7808 individual \item{}s in itemized lists addressable. Each \LM.. command 7849 individual \item{}s in itemized lists addressable. Each \LM.. command
7809 must occur on a separate line. \LMHash{} must occur immediately 7850 must occur on a separate line. \LMHash{} must occur immediately
7810 before the associated paragraph, and \LMLabel must occur immediately 7851 before the associated paragraph, and \LMLabel must occur immediately
7811 after the associated \section{}, \subsection{} etc. 7852 after the associated \section{}, \subsection{} etc.
7812 7853
7813 ---------------------------------------------------------------------- 7854 ----------------------------------------------------------------------
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698