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

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

Issue 396733003: Change rules so prefixes obey lexical scope. Do this by basing member access on objects uniformly. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« 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{dart} 3 \usepackage{dart}
4 \usepackage{bnf} 4 \usepackage{bnf}
5 \usepackage{hyperref} 5 \usepackage{hyperref}
6 \newcommand{\code}[1]{{\sf #1}} 6 \newcommand{\code}[1]{{\sf #1}}
7 \title{Dart Programming Language Specification \\ 7 \title{Dart Programming Language Specification \\
8 {\large Version 1.6}} 8 {\large Version 1.6}}
9 %\author{The Dart Team} 9 %\author{The Dart Team}
10 \begin{document} 10 \begin{document}
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 537
538 %A function declaration of the form $id(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{n+k} = d_k]) => e$ is equivalent to a varia ble declaration of the form \code{\FINAL{} $id$ = ($(T_1$ $a_1, \ldots, T_n$ $a _n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{n+k} = d_k])=> e$}. 538 %A function declaration of the form $id(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{n+k} = d_k]) => e$ is equivalent to a varia ble declaration of the form \code{\FINAL{} $id$ = ($(T_1$ $a_1, \ldots, T_n$ $a _n, [T_{n+1}$ $x_{n+1} = d_1, \ldots, T_{n+k}$ $x_{n+k} = d_k])=> e$}.
539 539
540 %A function literal of the form $(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+ 1} = d_1, \ldots, T_{n+k}$ $x_{n+k} = d_k]) => e$ is equivalent to a function li teral of the form \code{$(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_ 1, \ldots, T_{n+k}$ $x_{n+k} = d_k])\{$ \RETURN{} $e$;\}}. 540 %A function literal of the form $(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+ 1} = d_1, \ldots, T_{n+k}$ $x_{n+k} = d_k]) => e$ is equivalent to a function li teral of the form \code{$(T_1$ $a_1, \ldots, T_n$ $a_n, [T_{n+1}$ $x_{n+1} = d_ 1, \ldots, T_{n+k}$ $x_{n+k} = d_k])\{$ \RETURN{} $e$;\}}.
541 %} 541 %}
542 542
543 %A function declaration of the form $T_0$ $id(T_1$ $a_1, \ldots, T_n$ $a_n, \{T _{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})\{s\}$ is equivalent t o a variable declaration of the form \code{\FINAL{} $F$ $id$ = $(T_1$ $a_1, \ldo ts, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})\{s\ }$}, where $F$ is the function type alias (\ref{typedef}) \code{\TYPEDEF{} $T_0$ $F(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k} ]\}$}. Likewise, a function declaration of the form $id(T_1$ $a_1, \ldots, T_ n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})\{s\}$ is equivalent to a variable declaration of the form \code{\FINAL{} $F$ $id$ = $(T_1 $ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})\{s\}$}, where $F$ is the function type alias \code{\TYPEDEF{} $F(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\})$}. 543 %A function declaration of the form $T_0$ $id(T_1$ $a_1, \ldots, T_n$ $a_n, \{T _{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})\{s\}$ is equivalent t o a variable declaration of the form \code{\FINAL{} $F$ $id$ = $(T_1$ $a_1, \ldo ts, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})\{s\ }$}, where $F$ is the function type alias (\ref{typedef}) \code{\TYPEDEF{} $T_0$ $F(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k} ]\}$}. Likewise, a function declaration of the form $id(T_1$ $a_1, \ldots, T_ n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})\{s\}$ is equivalent to a variable declaration of the form \code{\FINAL{} $F$ $id$ = $(T_1 $ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1} : d_1, \ldots, T_{n+k}$ $x_{n+k} : d_k\})\{s\}$}, where $F$ is the function type alias \code{\TYPEDEF{} $F(T_1$ $a_1, \ldots, T_n$ $a_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\})$}.
544 544
545 It is a compile-time error to preface a function declaration with the built-in i dentifier \STATIC{}. 545 It is a compile-time error to preface a function declaration with the built-in i dentifier \STATIC{}.
546 546
547 When we say that a function $f_1$ {\em forwards} to another function $f_2$, we m ean that invoking $f_1$ causes $f_2$ to be executed with the same arguments an d/or receiver as $f_1$, and returns the result of executing $f_2$ to the caller of $f_1$, unless $f_2$ throws an exception, in which case $f_1$ throws the same exception. Furthermore, we only use the term for synthetic functions introduced by the specification.
548
549
547 \subsection{Formal Parameters} 550 \subsection{Formal Parameters}
548 \label{formalParameters} 551 \label{formalParameters}
549 552
550 Every function includes a {\em formal parameter list}, which consists of a list of required positional parameters (\ref{requiredFormals}), followed by any optio nal parameters (\ref{optionalFormals}). The optional parameters may be specified either as a set of named parameters or as a list of positional parameters, but not both. 553 Every function includes a {\em formal parameter list}, which consists of a list of required positional parameters (\ref{requiredFormals}), followed by any optio nal parameters (\ref{optionalFormals}). The optional parameters may be specified either as a set of named parameters or as a list of positional parameters, but not both.
551 554
552 The formal parameter list of a function introduces a new scope known as the func tion`s {\em formal parameter scope}. The formal parameter scope of a function $f $ is enclosed in the scope where $f$ is declared. Every formal parameter intr oduces a local variable into the formal parameter scope. However, the scope of a function's signature is the function's enclosing scope, not the formal paramete r scope. 555 The formal parameter list of a function introduces a new scope known as the func tion`s {\em formal parameter scope}. The formal parameter scope of a function $f $ is enclosed in the scope where $f$ is declared. Every formal parameter intr oduces a local variable into the formal parameter scope. However, the scope of a function's signature is the function's enclosing scope, not the formal paramete r scope.
553 556
554 The body of a function introduces a new scope known as the function`s {\em body scope}. The body scope of a function $f$ is enclosed in the scope introduced by the formal parameter scope of $f$. 557 The body of a function introduces a new scope known as the function`s {\em body scope}. The body scope of a function $f$ is enclosed in the scope introduced by the formal parameter scope of $f$.
555 558
556 559
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 \begin{grammar} 884 \begin{grammar}
882 {\bf getterSignature:} 885 {\bf getterSignature:}
883 returnType? \GET{} identifier 886 returnType? \GET{} identifier
884 . 887 .
885 \end{grammar} 888 \end{grammar}
886 889
887 %\Q{Why does a getter have a formal parameter list at all?} 890 %\Q{Why does a getter have a formal parameter list at all?}
888 891
889 If no return type is specified, the return type of the getter is \DYNAMIC{}. 892 If no return type is specified, the return type of the getter is \DYNAMIC{}.
890 893
891 A getter definition that is prefixed with the \STATIC{} modifier defines a stati c getter. Otherwise, it defines an instance getter. The name of the getter is gi ven by the identifier in the definition. 894 A getter definition that is prefixed with the \STATIC{} modifier defines a stati c getter. Otherwise, it defines an instance getter. The name of the getter is gi ven by the identifier in the definition. The effect of a static getter declarati on in class $C$ is to add an instance getter with the same name and signature to the \code{Type} object for class $C$ that forwards (\ref{functionDeclarations}) to the static getter.
892 895
893 %It is a compile-time error if a getter`s formal parameter list is not empty. 896 %It is a compile-time error if a getter`s formal parameter list is not empty.
894 897
895 The instance getters of a class $C$ are those instance getters declared by $C$, either implicitly or explicitly, and the instance getters inherited by $C$ from its superclass. The static getters of a class $C$ are those static getters decla red by $C$. 898 The instance getters of a class $C$ are those instance getters declared by $C$, either implicitly or explicitly, and the instance getters inherited by $C$ from its superclass. The static getters of a class $C$ are those static getters decla red by $C$.
896 899
897 It is a compile-time error if a class has both a getter and a method with the sa me name. This restriction holds regardless of whether the getter is defined expl icitly or implicitly, or whether the getter or the method are inherited or not. 900 It is a compile-time error if a class has both a getter and a method with the sa me name. This restriction holds regardless of whether the getter is defined expl icitly or implicitly, or whether the getter or the method are inherited or not.
898 901
899 \commentary{ 902 \commentary{
900 This implies that a getter can never override a method, and a method can never o verride a getter or field. 903 This implies that a getter can never override a method, and a method can never o verride a getter or field.
901 } 904 }
(...skipping 12 matching lines...) Expand all
914 % what about top level ones? Same for getters 917 % what about top level ones? Same for getters
915 918
916 \begin{grammar} 919 \begin{grammar}
917 {\bf setterSignature:} 920 {\bf setterSignature:}
918 returnType? \SET{} identifier formalParameterList 921 returnType? \SET{} identifier formalParameterList
919 . 922 .
920 \end{grammar} 923 \end{grammar}
921 924
922 If no return type is specified, the return type of the setter is \DYNAMIC{}. 925 If no return type is specified, the return type of the setter is \DYNAMIC{}.
923 926
924 A setter definition that is prefixed with the \STATIC{} modifier defines a stati c setter. Otherwise, it defines an instance setter. The name of a setter is obt ained by appending the string `=' to the identifier given in its signature. 927 A setter definition that is prefixed with the \STATIC{} modifier defines a stati c setter. Otherwise, it defines an instance setter. The name of a setter is obt ained by appending the string `=' to the identifier given in its signature. Th e effect of a static setter declaration in class $C$ is to add an instance sette r with the same name and signature to the \code{Type} object for class $C$ that forwards (\ref{functionDeclarations}) to the static setter.
925 928
926 \commentary{Hence, a setter name can never conflict with, override or be overrid den by a getter or method.} 929 \commentary{Hence, a setter name can never conflict with, override or be overrid den by a getter or method.}
927 930
928 The instance setters of a class $C$ are those instance setters declared by $C$ e ither implicitly or explicitly, and the instance setters inherited by $C$ from i ts superclass. The static setters of a class $C$ are those static setters declar ed by $C$. 931 The instance setters of a class $C$ are those instance setters declared by $C$ e ither implicitly or explicitly, and the instance setters inherited by $C$ from i ts superclass. The static setters of a class $C$ are those static setters declar ed by $C$.
929 932
930 It is a compile-time error if a setter's formal parameter list does not consist of exactly one required formal parameter $p$. \rationale{We could enforce this via the grammar, but we`d have to specify the evaluation rules in that case.} 933 It is a compile-time error if a setter's formal parameter list does not consist of exactly one required formal parameter $p$. \rationale{We could enforce this via the grammar, but we`d have to specify the evaluation rules in that case.}
931 934
932 %It is a compile-time error if a class has both a setter and a method with the s ame name. This restriction holds regardless of whether the setter is defined exp licitly or implicitly, or whether the setter or the method are inherited or not. 935 %It is a compile-time error if a class has both a setter and a method with the s ame name. This restriction holds regardless of whether the setter is defined exp licitly or implicitly, or whether the setter or the method are inherited or not.
933 936
934 It is a static warning if a setter declares a return type other than \VOID{}. 937 It is a static warning if a setter declares a return type other than \VOID{}.
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 1416
1414 When invoked from a constant object expression, a constant constructor must thro w an exception if any of its actual parameters is a value that would prevent one of the potentially constant expressions within it from being a valid compile-ti me constant. 1417 When invoked from a constant object expression, a constant constructor must thro w an exception if any of its actual parameters is a value that would prevent one of the potentially constant expressions within it from being a valid compile-ti me constant.
1415 1418
1416 %Discuss External Constructors in ne subsubsection here 1419 %Discuss External Constructors in ne subsubsection here
1417 1420
1418 \subsection{Static Methods} 1421 \subsection{Static Methods}
1419 \label{staticMethods} 1422 \label{staticMethods}
1420 1423
1421 {\em Static methods} are functions, other than getters or setters, whose declara tions are immediately contained within a class declaration and that are declared \STATIC{}. The static methods of a class $C$ are those static methods declared by $C$. 1424 {\em Static methods} are functions, other than getters or setters, whose declara tions are immediately contained within a class declaration and that are declared \STATIC{}. The static methods of a class $C$ are those static methods declared by $C$.
1422 1425
1426 The effect of a static method declaration in class $C$ is to add an instance met hod with the same name and signature to the \code{Type} object for class $C$ tha t forwards (\ref{functionDeclarations}) to the static method.
1427
1423 \rationale{ 1428 \rationale{
1424 Inheritance of static methods has little utility in Dart. Static methods cannot be overridden. Any required static function can be obtained from its declaring l ibrary, and there is no need to bring it into scope via inheritance. Experience shows that developers are confused by the idea of inherited methods that are not instance methods. 1429 Inheritance of static methods has little utility in Dart. Static methods cannot be overridden. Any required static function can be obtained from its declaring l ibrary, and there is no need to bring it into scope via inheritance. Experience shows that developers are confused by the idea of inherited methods that are not instance methods.
1425 1430
1426 Of course, the entire notion of static methods is debatable, but it is retained here because so many programmers are familiar with it. Dart static methods may b e seen as functions of the enclosing library. 1431 Of course, the entire notion of static methods is debatable, but it is retained here because so many programmers are familiar with it. Dart static methods may b e seen as functions of the enclosing library.
1427 } 1432 }
1428 1433
1429 It is a static warning if a class $C$ declares a static method named $n$ and has a setter named $n=$. 1434 It is a static warning if a class $C$ declares a static method named $n$ and has a setter named $n=$.
1430 %It is a static warning if a class has a static method with the same name as a s tatic member of one of its superclasses. 1435 %It is a static warning if a class has a static method with the same name as a s tatic member of one of its superclasses.
1431 1436
1432 %\rationale{ 1437 %\rationale{
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 newExpression; 2066 newExpression;
2062 constObjectExpression; 2067 constObjectExpression;
2063 `(' expression `)' 2068 `(' expression `)'
2064 . 2069 .
2065 2070
2066 \end{grammar} 2071 \end{grammar}
2067 2072
2068 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$. 2073 An expression $e$ may always be enclosed in parentheses, but this never has any semantic effect on $e$.
2069 2074
2070 \commentary{ 2075 \commentary{
2071 Sadly, it may have an effect on the surrounding expression. Given a class $C$ wi th static method $m => 42$, $C.m()$ returns 42, but $(C).m()$ produces a \code{N oSuchMethodError}. This anomaly can be corrected by ensuring that every instanc e of \code{Type} has instance members corresponding to its static members. This issue may be addressed in future versions of Dart . 2076 Sadly, it may have an effect on the surrounding expression. Given a class $C$ wi th static method $m => 42$, $C.m()$ returns 42, but $(C).m()$ produces a \code{N oSuchMethodError}. This anomaly can be corrected by removing the restrictions o n calling the members of instances of \code{Type}. This issue may be addressed i n future versions of Dart.
2072 } 2077 }
2073 2078
2074 \subsubsection{Object Identity} 2079 \subsubsection{Object Identity}
2075 \label{objectIdentity} 2080 \label{objectIdentity}
2076 2081
2077 The predefined Dart function \cd{identical()} is defined such that \code{identic al($c_1$, $c_2$)} iff: 2082 The predefined Dart function \cd{identical()} is defined such that \code{identic al($c_1$, $c_2$)} iff:
2078 \begin{itemize} 2083 \begin{itemize}
2079 \item $c_1$ evaluates to either \NULL{} or an instance of \code{bool} and \co de{$c_1$ == $c_2$}, OR 2084 \item $c_1$ evaluates to either \NULL{} or an instance of \code{bool} and \co de{$c_1$ == $c_2$}, OR
2080 \item $c_1$ and $c_2$ are instances of \code{int} and \code{$c_1$ == $c_2$}, OR 2085 \item $c_1$ and $c_2$ are instances of \code{int} and \code{$c_1$ == $c_2$}, OR
2081 \item $c_1$ and $c_2$ are constant strings and \code{$c_1$ == $c_2$}, OR 2086 \item $c_1$ and $c_2$ are constant strings and \code{$c_1$ == $c_2$}, OR
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 \begin{itemize} 2120 \begin{itemize}
2116 \item A literal number (\ref{numbers}). 2121 \item A literal number (\ref{numbers}).
2117 \item A literal boolean (\ref{booleans}). 2122 \item A literal boolean (\ref{booleans}).
2118 \item A literal string (\ref{strings}) where any interpolated expression (\ref{ stringInterpolation}) is a compile-time constant that evaluates to a numeric, st ring or boolean value or to \NULL{}. 2123 \item A literal string (\ref{strings}) where any interpolated expression (\ref{ stringInterpolation}) is a compile-time constant that evaluates to a numeric, st ring or boolean value or to \NULL{}.
2119 \rationale{It would be tempting to allow string interpolation where the interpol ated value is any compile-time constant. However, this would require running th e \code{toString()} method for constant objects, which could contain arbitrary c ode.} 2124 \rationale{It would be tempting to allow string interpolation where the interpol ated value is any compile-time constant. However, this would require running th e \code{toString()} method for constant objects, which could contain arbitrary c ode.}
2120 \item A literal symbol (\ref{symbols}). 2125 \item A literal symbol (\ref{symbols}).
2121 \item \NULL{} (\ref{null}). 2126 \item \NULL{} (\ref{null}).
2122 \item A qualified reference to a static constant variable (\ref{variables}) that is not qualified by a deferred prefix. 2127 \item A qualified reference to a static constant variable (\ref{variables}) that is not qualified by a deferred prefix.
2123 \commentary {For example, If class C declares a constant static variable v, C.v is a constant. The same is true if C is accessed via a prefix p; p.C.v is a cons tant unless p is a deferred prefix. 2128 \commentary {For example, If class C declares a constant static variable v, C.v is a constant. The same is true if C is accessed via a prefix p; p.C.v is a cons tant unless p is a deferred prefix.
2124 } 2129 }
2125 \item An identifier expression that denotes a constant variable. %CHANGE in goog ledoc 2130 \item An identifier expression that denotes a constant variable.
2126 \item A simple or qualified identifier denoting a class or a type alias. 2131 \item A qualified reference to a static constant variable (\ref{variables}) that is not qualified by a deferred prefix.
2127 \commentary {For example, if C is a class or typedef C is a constant, and if C i s imported with a prefix p, p.C is a constant. 2132 \commentary {For example, If class C declares a constant static variable v, C.v is a constant. The same is true if C is accessed via a prefix p; p.C.v is a cons tant unless p is a deferred prefix.
2128 } 2133 }
2129 \item A constant constructor invocation (\ref{const}) that is not qualified by a deferred prefix. 2134 \item A constant constructor invocation (\ref{const}) that is not qualified by a deferred prefix.
2130 \item A constant list literal (\ref{lists}). 2135 \item A constant list literal (\ref{lists}).
2131 \item A constant map literal (\ref{maps}). 2136 \item A constant map literal (\ref{maps}).
2132 \item A simple or qualified identifier denoting a top-level function (\ref{funct ions}) or a static method (\ref{staticMethods}) that is not qualified by a defer red prefix. 2137 \item A simple or qualified identifier denoting a top-level function (\ref{funct ions}) or a static method (\ref{staticMethods}) that is not qualified by a defer red prefix.
2133 \item A parenthesized expression \code{($e$)} where $e$ is a constant expression . 2138 \item A parenthesized expression \code{($e$)} where $e$ is a constant expression .
2134 \item An expression of the form \code{identical($e_1$, $e_2$)} where $e_1$ and $ e_2$ are constant expressions and \code{identical()} is statically bound to the predefined dart function \code{identical()} discussed above (\ref{objectIdent ity}). 2139 \item An expression of the form \code{identical($e_1$, $e_2$)} where $e_1$ and $ e_2$ are constant expressions and \code{identical()} is statically bound to the predefined dart function \code{identical()} discussed above (\ref{objectIdent ity}).
2135 \item An expression of one of the forms \code{$e_1$ == $e_2$} or \code{$e_1$ ! = $e_2$} where $e_1$ and $e_2$ are constant expressions that evaluate to a numer ic, string or boolean value or to \NULL{}. 2140 \item An expression of one of the forms \code{$e_1$ == $e_2$} or \code{$e_1$ ! = $e_2$} where $e_1$ and $e_2$ are constant expressions that evaluate to a numer ic, string or boolean value or to \NULL{}.
2136 \item An expression of one of the forms \code{!$e$}, \code{$e_1$ \&\& $e_2$} or \code{$e_1 || e_2$}, where $e$, $e_1$ and $e_2$ are constant expressions that e valuate to a boolean value. 2141 \item An expression of one of the forms \code{!$e$}, \code{$e_1$ \&\& $e_2$} or \code{$e_1 || e_2$}, where $e$, $e_1$ and $e_2$ are constant expressions that e valuate to a boolean value.
2137 \item An expression of one of the forms \~{}$e$, $e_1$ \^{} $e_2$, \code{$e_1$ \ & $e_2$}, $e_1 | e_2$, $e_1 >> e_2$ or $e_1 << e_2$, where $e$, $e_1$ and $e_2 $ are constant expressions that evaluate to an integer value or to \NULL{}. 2142 \item An expression of one of the forms \~{}$e$, $e_1$ \^{} $e_2$, \code{$e_1$ \ & $e_2$}, $e_1 | e_2$, $e_1 >> e_2$ or $e_1 << e_2$, where $e$, $e_1$ and $e_2 $ are constant expressions that evaluate to an integer value or to \NULL{}.
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 \label{spawningAnIsolate} 2987 \label{spawningAnIsolate}
2983 2988
2984 Spawning an isolate is accomplished via what is syntactically an ordinary librar y call, invoking one of the functions \code{spawnUri()} or \code{spawnFunction() }defined in the \code{dart:isolate} library. However, such calls have the sema ntic effect of creating a new isolate with its own memory and thread of control. 2989 Spawning an isolate is accomplished via what is syntactically an ordinary librar y call, invoking one of the functions \code{spawnUri()} or \code{spawnFunction() }defined in the \code{dart:isolate} library. However, such calls have the sema ntic effect of creating a new isolate with its own memory and thread of control.
2985 2990
2986 An isolate's memory is finite, as is the space available to its thread's call st ack. It is possible for a running isolate to exhaust its memory or stack, result ing in a run-time error that cannot be effectively caught, which will force the isolate to be suspended. 2991 An isolate's memory is finite, as is the space available to its thread's call st ack. It is possible for a running isolate to exhaust its memory or stack, result ing in a run-time error that cannot be effectively caught, which will force the isolate to be suspended.
2987 2992
2988 \commentary{ 2993 \commentary{
2989 As discussed in section \ref{errorsAndWarnings}, the handling of a suspended iso late is the responsibility of the embedder. 2994 As discussed in section \ref{errorsAndWarnings}, the handling of a suspended iso late is the responsibility of the embedder.
2990 } 2995 }
2991 2996
2992 \subsection{ Property Extraction}
2993 \label{propertyExtraction}
2994 2997
2995 {\em Property extraction} allows for a member of an object to be concisely extra cted from the object.
2996 If $e$ is an expression that evaluates to an object $o$, and if $m$ is the name of a concrete method member of $e$, then $e.m$ is defined to be equivalent to:
2997
2998 \begin{itemize}
2999
3000 \item
3001 \begin{dartCode}
3002 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{
3003 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$
3004 \}
3005 \end{dartCode}
3006
3007 if $m$ has required parameters $r_1, \ldots, r_n$, and named parameters $p_1, \l dots, p_k$ with defaults $d_1, \ldots, d_k$.
3008 \item
3009 \begin{dartCode}
3010 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{
3011 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$;
3012 \}
3013 \end{dartCode}
3014
3015 if $m$ has required parameters $r_1, \ldots, r_n$, and optional positional param eters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
3016 \end{itemize}
3017
3018 where $u$ is a fresh final variable bound to $o$, except that:
3019 \begin{enumerate}
3020 \item iff \code{identical($o_1, o_2$)} then \cd{$o_1.m$ == $o_2.m$}.
3021 \item The static type of the property extraction is the static type of function $T.m$, where $T$ is the static type of $e$, if $T.m$ is defined. Otherwise the s tatic type of $e.m$ is \DYNAMIC{}.
3022 \end{enumerate}
3023
3024 \commentary{
3025 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.
3026 }
3027 % local functions that have a closure extracted are always different
3028
3029 \rationale{
3030 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.
3031 }
3032
3033 Otherwise
3034 %, if $m$ is the name of a getter (\ref{getters}) member of $e$ (declared implic itly or explicitly) then
3035 $e.m$ is treated as a getter invocation (\ref{getterInvocation})).
3036
3037
3038 \commentary{Observations:
3039 \begin{enumerate}
3040 \item One cannot extract a getter or a setter.
3041 \item One can tell whether one implemented a property via a method or via field/ getter, which means that one has to plan ahead as to what construct to use, and that choice is reflected in the interface of the class.
3042 \end{enumerate}
3043 }
3044
3045 Let $S$ be the superclass of the immediately enclosing class. If $m$ is the name of a concrete method member of $S$, then the expression $\SUPER{}.m$ is define d to be equivalent to:
3046
3047 \begin{itemize}
3048 %\item $(r_1, \ldots, r_n)\{\RETURN{}$ $o.m(r_1, \ldots, r_n);\}$ if $m$ has on ly required parameters $r_1, \ldots r_n$.
3049 %\item $(r_1, \ldots, r_n, rest)\{return$ $o.m(r_1, \ldots, r_n, rest);\}$ if $ m$ has required parameters $r_1, \ldots r_n$, and a rest parameter $rest$.
3050 %\item
3051 \item
3052 \begin{dartCode}
3053 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$\{
3054 \RETURN{} \SUPER{}$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k)$;
3055 \}
3056 \end{dartCode}
3057
3058 if $m$ has required parameters $r_1, \ldots, r_n$, and named parameters $p_1, \l dots, p_k$ with defaults $d_1, \ldots, d_k$.
3059 \item
3060 \begin{dartCode}
3061 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{
3062 \RETURN{} \SUPER{}$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$;
3063 \}
3064 \end{dartCode}
3065
3066 if $m$ has required parameters $r_1, \ldots, r_n$, and optional positional param eters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
3067 \end{itemize}
3068
3069 Except that:
3070 \begin{enumerate}
3071 \item iff \code{identical($o_1, o_2$)} then \cd{$o_1.m$ == $o_2.m$}.
3072 \item
3073 The static type of the property extraction is the static type of the method $S.m $, if $S.m$ is defined. Otherwise the static type of $\SUPER{}.m$ is \DYNAMIC{} .
3074 \end{enumerate}
3075
3076 Otherwise
3077 %, if $m$ is the name of a getter (\ref{getters}) member of $S$ (declared implic itly or explicitly) then
3078 $\SUPER{}.m$ is treated as a getter invocation (\ref{getterInvocation})).
3079 2998
3080 \subsection{ Function Invocation} 2999 \subsection{ Function Invocation}
3081 \label{functionInvocation} 3000 \label{functionInvocation}
3082 3001
3083 Function invocation occurs in the following cases: when a function expression ( \ref{functionExpressions}) is invoked (\ref{functionExpressionInvocation}), when a method (\ref{methodInvocation}), getter (\ref{getterInvocation}) or setter (\ ref{assignment}) is invoked or when a constructor is invoked (either via instanc e creation (\ref{instanceCreation}), constructor redirection (\ref{redirectingCo nstructors}) or super initialization). The various kinds of function invocation differ as to how the function to be invoked, $f$, is determined, as well as whe ther \THIS{} is bound. Once $f$ has been determined, the formal parameters of $f $ are bound to corresponding actual arguments. The body of $f$ is then executed with the aforementioned bindings. Execution of the body terminates when the firs t of the following occurs: 3002 Function invocation occurs in the following cases: when a function expression ( \ref{functionExpressions}) is invoked (\ref{functionExpressionInvocation}), when a method (\ref{methodInvocation}), getter (\ref{topLevelGetterInvocation}, \ref {propertyExtraction}) or setter (\ref{assignment}) is invoked or when a construc tor is invoked (either via instance creation (\ref{instanceCreation}), construct or redirection (\ref{redirectingConstructors}) or super initialization). The var ious kinds of function invocation differ as to how the function to be invoked, $ f$, is determined, as well as whether \THIS{} is bound. Once $f$ has been deter mined, the formal parameters of $f$ are bound to corresponding actual arguments. The body of $f$ is then executed with the aforementioned bindings. Execution of the body terminates when the first of the following occurs:
3084 \begin{itemize} 3003 \begin{itemize}
3085 \item An uncaught exception is thrown. 3004 \item An exception is thrown and not caught within the current function activati on.
3086 \item A return statement (\ref{return}) immediately nested in the body of $f$ is executed. 3005 \item A return statement (\ref{return}) immediately nested in the body of $f$ is executed.
3087 \item The last statement of the body completes execution. 3006 \item The last statement of the body completes execution.
3088 \end{itemize} 3007 \end{itemize}
3089 3008
3090 3009
3091 3010
3092 3011
3093 \subsubsection{ Actual Argument List Evaluation} 3012 \subsubsection{ Actual Argument List Evaluation}
3094 \label{actualArguments} 3013 \label{actualArguments}
3095 3014
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3149 3068
3150 Let $T_i$ be the static type of $a_i$, let $S_i$ be the type of $p_i, i \in 1 .. h+k$ and let $S_q$ be the type of the named parameter $q$ of $f$. It is a stat ic warning if $T_j$ may not be assigned to $S_j, j \in 1..m$. It is a static wa rning if $m < h$ or if $m > n$. Furthermore, each $q_i, 1 \le i \le l$, must ha ve a corresponding named parameter in the set $\{p_{n+1}, \ldots, p_{n +k}\}$ or a static warning occurs. It is a static warning if $T_{m+j}$ may not be assign ed to $S_{q_j}, j \in 1 .. l$. 3069 Let $T_i$ be the static type of $a_i$, let $S_i$ be the type of $p_i, i \in 1 .. h+k$ and let $S_q$ be the type of the named parameter $q$ of $f$. It is a stat ic warning if $T_j$ may not be assigned to $S_j, j \in 1..m$. It is a static wa rning if $m < h$ or if $m > n$. Furthermore, each $q_i, 1 \le i \le l$, must ha ve a corresponding named parameter in the set $\{p_{n+1}, \ldots, p_{n +k}\}$ or a static warning occurs. It is a static warning if $T_{m+j}$ may not be assign ed to $S_{q_j}, j \in 1 .. l$.
3151 3070
3152 \subsubsection{ Unqualified Invocation} 3071 \subsubsection{ Unqualified Invocation}
3153 \label{unqualifiedInvocation} 3072 \label{unqualifiedInvocation}
3154 3073
3155 An unqualified function invocation $i$ has the form 3074 An unqualified function invocation $i$ has the form
3156 3075
3157 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, 3076 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$,
3158 3077
3159 where $id$ is an identifier or an identifier qualified with a library prefix. 3078 where $id$ is an identifier.
3160
3161 If $id$ is qualified with a deferred prefix $p$ and $p$ has not been successfull y loaded, then:
3162 \begin{itemize}
3163 \item
3164 If the invocation has the form $p$\code{.loadLibrary()} then an attempt to load the library represented by the prefix $p$ is initiated as discussed in section \ ref{imports}.
3165 \item
3166 Otherwise, a \code{NoSuchMethodError} is thrown.
3167 \end{itemize}
3168 3079
3169 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the innermost such declaration. Then: 3080 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the innermost such declaration. Then:
3170 \begin{itemize} 3081 \begin{itemize}
3171 \item 3082 \item
3172 If $f_{id}$ is a local function, a library function, a library or static getter or a variable then $i$ is interpreted as a function expression invocation (\ref {functionExpressionInvocation}). 3083 If $f_{id}$ is a local function, a library function, a library or static getter or a variable then $i$ is interpreted as a function expression invocation (\ref {functionExpressionInvocation}).
3173 \item 3084 \item
3174 Otherwise, if $f_{id}$ is a static method of the enclosing class $C$, $i$ is equ ivalent to $C.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}) $. 3085 Otherwise, if $f_{id}$ is a static method of the enclosing class $C$, $i$ is equ ivalent to $C.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}) $.
3175 \item Otherwise, $f_{id}$ is considered equivalent to the ordinary method invoca tion $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}) $. 3086 \item Otherwise, $f_{id}$ is considered equivalent to the ordinary method invoca tion $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}) $.
3176 \end{itemize} 3087 \end{itemize}
3177 3088
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3211 3122
3212 \commentary{ 3123 \commentary{
3213 The implication of this definition, and the other definitions involving the meth od \code{call()}, is that user defined types can be used as function values prov ided they define a \CALL{} method. The method \CALL{} is special in this regard. The signature of the \CALL{} method determines the signature used when using th e object via the built-in invocation syntax. 3124 The implication of this definition, and the other definitions involving the meth od \code{call()}, is that user defined types can be used as function values prov ided they define a \CALL{} method. The method \CALL{} is special in this regard. The signature of the \CALL{} method determines the signature used when using th e object via the built-in invocation syntax.
3214 } 3125 }
3215 3126
3216 It is a static warning if the static type $F$ of $e_f$ may not be assigned to a function type. If $F$ is not a function type, the static type of $i$ is \DYNAMI C{}. Otherwise 3127 It is a static warning if the static type $F$ of $e_f$ may not be assigned to a function type. If $F$ is not a function type, the static type of $i$ is \DYNAMI C{}. Otherwise
3217 the static type of $i$ is the declared return type of $F$. 3128 the static type of $i$ is the declared return type of $F$.
3218 %\item Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static war ning if $F$ is not a supertype of $(T_1, \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldot s, T_{n+k}$ $x_{n+k}]) \to \bot$. 3129 %\item Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static war ning if $F$ is not a supertype of $(T_1, \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldot s, T_{n+k}$ $x_{n+k}]) \to \bot$.
3219 %\end{itemize} 3130 %\end{itemize}
3220 3131
3132 \subsection{Lookup}
3133
3134 \subsubsection{Method Lookup}
3135 \label{methodLookup}
3136
3137 The result of a lookup of a method $m$ in object $o$ with respect to library $L$ is the result of a lookup of method $m$ in class $C$ with respect to library $ L$, where $C$ is the class of $o$.
3138
3139 The result of a lookup of method $m$ in class $C$ with respect to library $L$ i s:
3140 If $C$ declares a concrete instance method named $m$ that is accessible to $L$, then that method is the result of the lookup. Otherwise, if $C$ has a superclas s $S$, then the result of the lookup is the result of looking up $m$ in $S$ wit h respect to $L$. Otherwise, we say that the method lookup has failed.
3141
3142 \rationale {
3143 The motivation for skipping abstract members during lookup is largely to allow s moother mixin composition.
3144 }
3145
3146
3147 \subsubsection{ Getter and Setter Lookup}
3148 \label{getterAndSetterLookup}
3149
3150 The result of a lookup of a getter (respectively setter) $m$ in object $o$ with respect to library $L$ is the result of looking up getter (respectively sette r) $m$ in class $C$ with respect to $L$, where $C$ is the class of $o$.
3151
3152 The result of a lookup of a getter (respectively setter) $m$ in class $C$ with respect to library $L$ is:
3153 If $C$ declares a concrete instance getter (respectively setter) named $m$ that is accessible to $L$, then that getter (respectively setter) is the result of the lookup. Otherwise, if $C$ has a superclass $S$, then the result of the looku p is the result of looking up getter (respectively setter) $m$ in $S$ with respe ct to $L$. Otherwise, we say that the lookup has failed.
3154
3155 \rationale {
3156 The motivation for skipping abstract members during lookup is largely to allow s moother mixin composition.
3157 }
3158
3159
3160 \subsection{Top level Getter Invocation}
3161 \label{topLevelGetterInvocation}
3162
3163 Evaluation of a top-level getter invocation $i$ of the form $m$, where $m$ is an identifier, proceeds as follows:
3164
3165 The getter function $m$ is invoked. The value of $i$ is the result returned by t he call to the getter function.
3166 \commentary{
3167 Note that the invocation is always defined. Per the rules for identifier referen ces, an identifier will not be treated as a top-level getter invocation unless t he getter $i$ is defined.
3168 }
3169
3170 The static type of $i$ is the declared return type of $m$.
3221 3171
3222 \subsection{ Method Invocation} 3172 \subsection{ Method Invocation}
3223 \label{methodInvocation} 3173 \label{methodInvocation}
3224 3174
3225 Method invocation can take several forms as specified below. 3175 Method invocation can take several forms as specified below.
3226 3176
3227 \subsubsection{Ordinary Invocation} 3177 \subsubsection{Ordinary Invocation}
3228 \label{ordinaryInvocation} 3178 \label{ordinaryInvocation}
3229 3179
3230 An ordinary method invocation $i$ has the form 3180 An ordinary method invocation $i$ has the form
3231 3181
3232 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ where $o$ is not the name of a class or a library prefix. 3182 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3233
3234 Method invocation involves method lookup, defined next.
3235 The result of a lookup of a method $m$ in object $o$ with respect to library $L$ is the result of a lookup of method $m$ in class $C$ with respect to library $ L$, where $C$ is the class of $o$.
3236
3237 The result of a lookup of method $m$ in class $C$ with respect to library $L$ i s:
3238 If $C$ declares a concrete instance method named $m$ that is accessible to $L$, then that method is the result of the lookup. Otherwise, if $C$ has a superclas s $S$, then the result of the lookup is the result of looking up $m$ in $S$ wit h respect to $L$. Otherwise, we say that the method lookup has failed.
3239
3240 \rationale {
3241 The motivation for skipping abstract members during lookup is largely to allow s moother mixin composition.
3242 }
3243 3183
3244 Evaluation of an ordinary method invocation $i$ of the form 3184 Evaluation of an ordinary method invocation $i$ of the form
3245 3185
3246 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ 3186 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$
3247 3187
3248 proceeds as follows: 3188 proceeds as follows:
3249 3189
3250 First, the expression $o$ is evaluated to a value $v_o$. Next, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k}$. Let $f$ be the result of looking up method $m$ in $v_o$ with respect to the current library $L$. 3190 First, the expression $o$ is evaluated to a value $v_o$. Next, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k}$. Let $f$ be the result of looking up (\ref{methodLookup}) method $m$ in $v_o$ with respect to the cur rent library $L$.
3251 3191
3252 Let $p_1 \ldots p_h$ be the required parameters of $f$, let $p_1 \ldots p_m$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+l}$ be the opti onal parameters declared by $f$. 3192 Let $p_1 \ldots p_h$ be the required parameters of $f$, let $p_1 \ldots p_m$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+l}$ be the opti onal parameters declared by $f$.
3253 3193
3254 \commentary{ 3194 \commentary{
3255 We have an argument list consisting of $n$ positional arguments and $k$ named ar guments. We have a function with $h$ required parameters and $l$ optional parame ters. The number of positional arguments must be at least as large as the number of required parameters, and no larger than the number of positional parameters. All named arguments must have a corresponding named parameter. 3195 We have an argument list consisting of $n$ positional arguments and $k$ named ar guments. We have a function with $h$ required parameters and $l$ optional parame ters. The number of positional arguments must be at least as large as the number of required parameters, and no larger than the number of positional parameters. All named arguments must have a corresponding named parameter.
3256 } 3196 }
3257 3197
3258 If $n < h$, or $n > m$, the method lookup has failed. Furthermore, each $x_i, n +1 \le i \le n+k$, must have a corresponding named parameter in the set $\{p_{m +1}, \ldots, p_{h+l}\}$ or the method lookup also fails. Otherwise method looku p has succeeded. 3198 If $n < h$, or $n > m$, the method lookup has failed. Furthermore, each $x_i, n +1 \le i \le n+k$, must have a corresponding named parameter in the set $\{p_{m +1}, \ldots, p_{h+l}\}$ or the method lookup also fails. If $v_o$ is an instanc e of \code{Type} but $o$ is not a constant type literal, then if $m$ is a method that forwards (\ref{functionDeclarations}) to a static method, method lookup fa ils. Otherwise method lookup has succeeded.
3259 3199
3260 If the method lookup succeeded, the body of $f$ is executed with respect to the bindings that resulted from the evaluation of the argument list, and with \THIS{ } bound to $v_o$. The value of $i$ is the value returned after $f$ is executed. 3200 If the method lookup succeeded, the body of $f$ is executed with respect to the bindings that resulted from the evaluation of the argument list, and with \THIS{ } bound to $v_o$. The value of $i$ is the value returned after $f$ is executed.
3261 3201
3262 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $v_o$ with respect to $L$. If the getter l ookup succeeded, let $v_g$ be the value of the getter invocation $o.m$. Then the value of $i$ is the result of invoking 3202 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $v_o$ with respect to $L$.
3203 f $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, th en if $g$ is a getter that forwards to a static getter, getter lookup fails.
3204 If the getter lookup succeeded, let $v_g$ be the value of the getter invocation $o.m$. Then the value of $i$ is the result of invoking
3263 the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_ n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$. 3205 the static method \code{Function.apply()} with arguments $v.g, [o_1, \ldots , o_ n], \{x_{n+1}: o_{n+1}, \ldots , x_{n+k}: o_{n+k}\}$.
3264 3206
3265 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : 3207 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that :
3266 \begin{itemize} 3208 \begin{itemize}
3267 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3209 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3268 \item \code{im.memberName} evaluates to \code{'m'}. 3210 \item \code{im.memberName} evaluates to \code{'m'}.
3269 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. 3211 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}.
3270 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}. 3212 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}.
3271 \end{itemize} 3213 \end{itemize}
3272 3214
3273 Then the method \code{noSuchMethod()} is looked up in $o$ and invoked with argum ent $im$, and the result of this invocation is the result of evaluating $i$. How ever, if the implementation found cannot be invoked with a single positional arg ument, the implementation of \code{noSuchMethod()} in class \code{Object} is in voked on $o$ with argument $im'$, where $im'$ is an instance of \code{Invocation } such that : 3215 Then the method \code{noSuchMethod()} is looked up in $v_o$ and invoked with arg ument $im$, and the result of this invocation is the result of evaluating $i$. H owever, if the implementation found cannot be invoked with a single positional a rgument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $v_o$ with argument $im'$, where $im'$ is an instance of \code{Invoca tion} such that :
3274 \begin{itemize} 3216 \begin{itemize}
3275 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3217 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3276 \item \code{im.memberName} evaluates to \code{noSuchMethod'}. 3218 \item \code{im.memberName} evaluates to \code{noSuchMethod'}.
3277 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. 3219 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$.
3278 \item \code{im.namedArguments} evaluates to an empty immutable map. 3220 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3279 \end{itemize} 3221 \end{itemize}
3280 3222
3281 and the result of the latter invocation is the result of evaluating $i$. 3223 and the result of the latter invocation is the result of evaluating $i$.
3282 3224
3283 \rationale { 3225 \rationale {
3284 It is possible to bring about such a situation by overriding \code{noSuchMethod( )} with the wrong number of arguments:} 3226 It is possible to bring about such a situation by overriding \code{noSuchMethod( )} with the wrong number of arguments:}
3285 3227
3286 \begin{code} 3228 \begin{code}
3287 \CLASS{} Perverse \{ 3229 \CLASS{} Perverse \{
3288 noSuchMethod(x,y) =$>$ x + y; 3230 noSuchMethod(x,y) =$>$ x + y;
3289 \} 3231 \}
3290 3232
3291 \NEW{} Perverse.unknownMethod(); 3233 \NEW{} Perverse.unknownMethod();
3292 \end{code} 3234 \end{code}
3293 3235
3294 \commentary{Notice that the wording carefully avoids re-evaluating the receiver $o$ and the arguments $a_i$. } 3236 \commentary{Notice that the wording carefully avoids re-evaluating the receiver $o$ and the arguments $a_i$. }
3295 3237
3296 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 $T$ or a su perinterface of $T$ is annotated with an annotation denoting a constant identica l to the constant \code{@proxy} defined in \code{dart:core}. If $T.m$ exists, it is a static type warning if the type $F$ of $T.m$ may not be assigned to a f unction type. If $T.m$ does not exist, or if $F$ is not a function type, the sta tic type of $i$ is \DYNAMIC{}; otherwise the static type of $i$ is the declared return type of $F$. 3238 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:
3297 % The following is not needed because it is specified in 'Binding Actuals to For mals" Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static warn ing if $F$ is not a supertype of $(T_1, \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldot s, T_{n+k}$ $x_{n+k}\}) \to \bot$. 3239 \begin{itemize}
3240 \item
3241 $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
3242 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static getter named $m$.
3243 \end{itemize}
3298 3244
3245 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$.
3299 3246
3300 3247 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 `.'.
3301 %\subsubsection{This Invocation}
3302 % Maybe this has no significance the way the language is set up?
3303 3248
3304 3249
3305 \subsubsection{Cascaded Invocations} 3250 \subsubsection{Cascaded Invocations}
3306 \label{cascadedInvocations} 3251 \label{cascadedInvocations}
3307 3252
3308 A {\em cascaded method invocation} has the form {\em e..suffix} 3253 A {\em cascaded method invocation} has the form {\em e..suffix}
3309 where $e$ is an expression and {\em suffix} is a sequence of operator, method, g etter or setter invocations. 3254 where $e$ is an expression and {\em suffix} is a sequence of operator, method, g etter or setter invocations.
3310 3255
3311 \begin{grammar} 3256 \begin{grammar}
3312 {\bf cascadeSection:} 3257 {\bf cascadeSection:}
3313 `{\escapegrammar ..}' (cascadeSelector arguments*) (assignableSelector arg uments*)* (assignmentOperator expressionWithoutCascade)? 3258 `{\escapegrammar ..}' (cascadeSelector arguments*) (assignableSelector arg uments*)* (assignmentOperator expressionWithoutCascade)?
3314 . 3259 .
3315 3260
3316 {\bf cascadeSelector:}`[' expression `]'; 3261 {\bf cascadeSelector:}`[' expression `]';
3317 identifier 3262 identifier
3318 . 3263 .
3319 \end{grammar} 3264 \end{grammar}
3320 3265
3321 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$)}. 3266 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$)}.
3322 3267
3323 \subsubsection{Static Invocation}
3324 \label{staticInvocation}
3325
3326 A static method invocation $i$ has the form
3327
3328 $C.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$
3329
3330 where $C$ denotes a class in the current scope.
3331
3332 It is a static warning if $C$ does not declare a static method or getter $m$.
3333
3334 \rationale{
3335 Note that the absence of $C.m$ is statically detectable. Nevertheless, we choose not to define this situation as an error. The goal is to allow coding to proce ed in the order that suits the developer rather than eagerly insisting on consis tency. The warnings are given statically at compile-time to help developers catc h errors. However, developers need not correct these problems immediately in ord er to make progress.
3336 }
3337
3338 \commentary{
3339 Note the requirement that $C$ {\em declare} the method. This means that static m ethods declared in superclasses of $C$ cannot be invoked via $C$.
3340 }
3341
3342
3343 Evaluation of $i$ proceeds as follows:
3344
3345 If $C$ is a deferred type (\ref{staticTypes}) with prefix $p$, and $p$ has not been successfully loaded, or
3346 if $C$ does not declare a static method or getter $m$ then the argument list $(a _1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is evaluated, af ter which a \code{NoSuchMethodError} is thrown.
3347
3348 Otherwise, evaluation proceeds as follows:
3349 \begin{itemize}
3350 \item
3351 If the member $m$ declared by $C$ is a getter, then $i$ is equivalent to the exp ression $(C.m)(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3352 \item Otherwise, let $f$ be the the method $m$ declared in class $C$. Next, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is evaluated.
3353 The body of $f$ is then executed with respect to the bindings that resulted from the evaluation of the argument list. The value of $i$ is the value returned aft er the body of $f$ is executed.
3354 \end{itemize}
3355
3356 It is a static type warning if the type $F$ of $C.m$ may not be assigned to a fu nction type. If $F$ is not a function type, or if $C.m$ does not exist, the sta tic type of $i$ is \DYNAMIC{}. Otherwise
3357 the static type of $i$ is the declared return type of $F$.
3358 % The following is not needed because it is specified in 'Binding Actuals to For mals"Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static warni ng if $F$ is not a supertype of $(T_1, \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots , T_{n+k}$ $x_{n+k}\}) \to \bot$.
3359
3360
3361
3362
3363 \subsubsection{Super Invocation} 3268 \subsubsection{Super Invocation}
3364 \label{superInvocation} 3269 \label{superInvocation}
3365 3270
3366 A super method invocation $i$ has the form 3271 A super method invocation $i$ has the form
3367 3272
3368 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3273 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3369 3274
3370 Evaluation of $i$ proceeds as follows: 3275 Evaluation of $i$ proceeds as follows:
3371 3276
3372 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k }$. Let $S$ be the superclass of the immediately enclosing class, and let $f$ be the result of looking up method (\ref{ordinaryInvocation}) $m$ in $S$ with re spect to the current library $L$. 3277 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k }$. Let $S$ be the superclass of the immediately enclosing class, and let $f$ be the result of looking up method (\ref{ordinaryInvocation}) $m$ in $S$ with re spect to the current library $L$.
(...skipping 11 matching lines...) Expand all
3384 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3289 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3385 \item \code{im.memberName} evaluates to \code{'m'}. 3290 \item \code{im.memberName} evaluates to \code{'m'}.
3386 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. 3291 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}.
3387 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}. 3292 \item \code{im.namedArguments} evaluates to an immutable map with the same keys and values as \code{\{$x_{n+1}: o_{n+1}, \ldots, x_{n+k} : o_{n+k}$\}}.
3388 \end{itemize} 3293 \end{itemize}
3389 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked on \THIS{} with argument $im$, and the result of this invocation is the result of evaluati ng $i$. However, if the implementation found cannot be invoked with a single pos itional argument, the implementation of \code{noSuchMethod()} in class \code{Ob ject} is invoked on \THIS{} with argument $im'$, where $im'$ is an instance of \ code{Invocation} such that : 3294 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked on \THIS{} with argument $im$, and the result of this invocation is the result of evaluati ng $i$. However, if the implementation found cannot be invoked with a single pos itional argument, the implementation of \code{noSuchMethod()} in class \code{Ob ject} is invoked on \THIS{} with argument $im'$, where $im'$ is an instance of \ code{Invocation} such that :
3390 \begin{itemize} 3295 \begin{itemize}
3391 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3296 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3392 \item \code{im.memberName} evaluates to \code{noSuchMethod}. 3297 \item \code{im.memberName} evaluates to \code{noSuchMethod}.
3393 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. 3298 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$.
3394 \item \code{im.namedArguments} evaluates to an empty immutable map. 3299 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3395 \end{itemize} 3300 \end{itemize}
3396 3301
3397 and the result of this latter invocation is the result of evaluating $i$. 3302 and the result of this latter invocation is the result of evaluating $i$.
3398 3303
3399 3304
3400 It is a compile-time error if a super method invocation occurs in a top-level fu nction or variable initializer, in an instance variable initializer or initializ er list, in class \code{Object}, in a factory constructor or in a static method or variable initializer. 3305 It is a compile-time error if a super method invocation occurs in a top-level fu nction or variable initializer, in an instance variable initializer or initializ er list, in class \code{Object}, in a factory constructor or in a static method or variable initializer.
3401 3306
3402 It is a static type warning if $S$ does not have an accessible (\ref{privacy}) i nstance member named $m$ unless $S$ or a superinterface of $S$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defin ed in \code{dart:core}. If $S.m$ exists, it is a static type warning if the typ e $F$ of $S.m$ may not be assigned to a function type. If $S.m$ does not exist, or if $F$ is not a function type, the static type of $i$ is \DYNAMIC{}; otherwis e the static type of $i$ is the declared return type of $F$. 3307 It is a static type warning if $S$ does not have an accessible (\ref{privacy}) i nstance member named $m$ unless $S$ or a superinterface of $S$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defin ed in \code{dart:core}. If $S.m$ exists, it is a static type warning if the typ e $F$ of $S.m$ may not be assigned to a function type. If $S.m$ does not exist, or if $F$ is not a function type, the static type of $i$ is \DYNAMIC{}; otherwis e the static type of $i$ is the declared return type of $F$.
3403 % The following is not needed because it is specified in 'Binding Actuals to For mals" 3308 % The following is not needed because it is specified in 'Binding Actuals to For mals"
3404 %Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static warning i f $F$ is not a supertype of $(T_1, \ldots, t_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_ {n+k}$ $x_{n+k}\}) \to \bot$. 3309 %Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static warning i f $F$ is not a supertype of $(T_1, \ldots, t_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_ {n+k}$ $x_{n+k}\}) \to \bot$.
3405 3310
3406 3311
3407 3312
3408 3313
3409 \subsubsection{Sending Messages} 3314 \subsubsection{Sending Messages}
3410 3315
3411 \label{sendingMessages} 3316 \label{sendingMessages}
3412 3317
3413 Messages are the sole means of communication among isolates. Messages are sent b y invoking specific methods in the Dart libraries; there is no specific syntax for sending a message. 3318 Messages are the sole means of communication among isolates. Messages are sent b y invoking specific methods in the Dart libraries; there is no specific syntax for sending a message.
3414 3319
3415 \commentary{In other words, the methods supporting sending messages embody primi tives of Dart that are not accessible to ordinary code, much like the methods th at spawn isolates. 3320 \commentary{In other words, the methods supporting sending messages embody primi tives of Dart that are not accessible to ordinary code, much like the methods th at spawn isolates.
3416 } 3321 }
3417 3322
3418 3323
3419 \subsection{ Getter and Setter Lookup}
3420 \label{getterAndSetterLookup}
3421 3324
3422 The result of a lookup of a getter (respectively setter) $m$ in object $o$ with respect to library $L$ is the result of looking up getter (respectively sette r) $m$ in class $C$ with respect to $L$, where $C$ is the class of $o$. 3325 \subsection{ Property Extraction}
3326 \label{propertyExtraction}
3423 3327
3424 The result of a lookup of a getter (respectively setter) $m$ in class $C$ with respect to library $L$ is: 3328 {\em Property extraction} allows for a member of an object to be concisely extra cted from the object.
3425 If $C$ declares a concrete instance getter (respectively setter) named $m$ that is accessible to $L$, then that getter (respectively setter) is the result of the lookup. Otherwise, if $C$ has a superclass $S$, then the result of the looku p is the result of looking up getter (respectively setter) $m$ in $S$ with respe ct to $L$. Otherwise, we say that the lookup has failed. 3329 A property extraction can be either:
3330 \begin{enumerate}
3331 \item A {\em closurization} (\ref{closurization}) which allows a method to be tr eated as if it were a getter for a function valued object. Or
3332 \item A {\em getter invocation} which returns the result of invoking of a getter method.
3333 \end{enumerate}
3426 3334
3427 \rationale { 3335 Evaluation of a property extraction $i$ of the form $e.m$ proceeds as follows:
3428 The motivation for skipping abstract members during lookup is largely to allow s moother mixin composition.
3429 }
3430 3336
3431 \subsection{ Getter Invocation} 3337 First, the expression $e$ is evaluated to an object $o$. Let $f$ be the result o f looking up (\ref{methodLookup}) method (\ref{instanceMethods}) $m$ in $o$ wit h respect to the current library $L$. If $o$ is an instance of \code{Type} but $e$ is not a constant type literal, then if $m$ is a method that forwards (\ref{ functionDeclarations}) to a static method, method lookup fails. If method looku p succeeds and $f$ is a concrete method then $i$ evaluates to the closurization of $o.m$.
3432 \label{getterInvocation}
3433 3338
3434 A getter invocation provides access to the value of a property. 3339 Otherwise, $i$ is a getter invocation, and the getter function (\ref{getters}) $ m$ is looked up (\ref{getterAndSetterLookup}) in $o$ with respect to $L$. If $o $ is an instance of \code{Type} but $e$ is not a constant type literal, then if $m$ is a getter that forwards to a static getter, getter lookup fails. Otherwi se, the body of $m$ is executed with \THIS{} bound to $o$. The value of $i$ is the result returned by the call to the getter function.
3435
3436 Evaluation of a getter invocation $i$ of the form $e.m$ proceeds as follows:
3437
3438 First, the expression $e$ is evaluated to an object $o$. Then, the getter functi on (\ref{getters}) $m$ is looked up (\ref{getterAndSetterLookup}) in $o$ with r espect to the current library, and its body is executed with \THIS{} bound to $ o$. The value of the getter invocation expression is the result returned by the call to the getter function.
3439
3440 3340
3441 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : 3341 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that :
3442 \begin{itemize} 3342 \begin{itemize}
3443 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. 3343 \item \code{im.isGetter} evaluates to \code{\TRUE{}}.
3444 \item \code{im.memberName} evaluates to \code{'m'}. 3344 \item \code{im.memberName} evaluates to \code{'m'}.
3445 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . 3345 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} .
3446 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 3346 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3447 \end{itemize} 3347 \end{itemize}
3448 Then the method \code{noSuchMethod()} is looked up in $o$ and invoked with argu ment $im$, and the result of this invocation is the result of evaluating $i$. Ho wever, if the implementation found cannot be invoked with a single positional ar gument, the implementation of \code{noSuchMethod()} in class \code{Object} is i nvoked on $o$ with argument $im'$, where $im'$ is an instance of \code{Invocatio n} such that : 3348 Then the method \code{noSuchMethod()} is looked up in $o$ and invoked with argu ment $im$, and the result of this invocation is the result of evaluating $i$. Ho wever, if the implementation found cannot be invoked with a single positional ar gument, the implementation of \code{noSuchMethod()} in class \code{Object} is i nvoked on $o$ with argument $im'$, where $im'$ is an instance of \code{Invocatio n} such that :
3449 \begin{itemize} 3349 \begin{itemize}
3450 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3350 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3451 \item \code{im.memberName} evaluates to \code{noSuchMethod}. 3351 \item \code{im.memberName} evaluates to \code{noSuchMethod}.
3452 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. 3352 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$.
3453 \item \code{im.namedArguments} evaluates to an empty immutable map. 3353 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3454 \end{itemize} 3354 \end{itemize}
3455 3355
3456 and the result of this latter invocation is the result of evaluating $i$. 3356 and the result of this latter invocation is the result of evaluating $i$.
3457 3357
3458 Let $T$ be the static type of $e$. It is a static type warning if $T$ does not have a getter named $m$ unless $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} define d in \code{dart:core}. The static type of $i$ is the declared return type of $T. m$, if $T.m$ exists; otherwise the static type of $i$ is \DYNAMIC{}. 3358 It is a compile-time error if $m$ is a member of class \cd{Object} and $e$ is ei ther a prefix object (\ref{imports}) or a constant type literal.
3459 3359
3460 Evaluation of a getter invocation $i$ of the form $C.m$ proceeds as follows: 3360 \commentary {
3461 3361 This precludes \code{int.toString} but not \code{(int).toString} because in the latter case, $e$ is a parenthesized expression.
3462 If there is no class $C$ in the enclosing lexical scope of $i$, or if $C$ does not declare, implicitly or explicitly, a getter named $m$, then a \code{NoSuchM ethodError} is thrown.
3463 Otherwise, the getter function $C.m$ is invoked. The value of $i$ is the result returned by the call to the getter function.
3464
3465 It is a static warning if there is no class $C$ in the enclosing lexical scope of $i$, or if $C$ does not declare, implicitly or explicitly, a getter named $m $. The static type of $i$ is the declared return type of $C.m$ if it exists or \ DYNAMIC{} otherwise.
3466
3467 Evaluation of a top-level getter invocation $i$ of the form $m$, where $m$ is an identifier, proceeds as follows:
3468
3469 The getter function $m$ is invoked. The value of $i$ is the result returned by t he call to the getter function.
3470 \commentary{
3471 Note that the invocation is always defined. Per the rules for identifier referen ces, an identifier will not be treated as a top-level getter invocation unless t he getter $i$ is defined.
3472 } 3362 }
3473 3363
3474 The static type of $i$ is the declared return type of $m$. 3364 Let $T$ be the static type of $e$. It is a static type warning if $T$ does not have a method or getter named $m$ unless either:
3365 \begin{itemize}
3366 \item
3367 $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
3368 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static method or getter named $m$.
3369 \end{itemize}
3475 3370
3476 Evaluation of super getter invocation $i$ of the form $\SUPER{}.m$ proceeds as f ollows: 3371 If $i$ is a getter invocation, the static type of $i$ is:
3372 \begin{itemize}
3373 \item The declared return type of $T.m$, if $T.m$ exists.
3374 \item The declared return type of $m$, if $T$ is \code{Type}, $e$ is a constant type literal and the class corresponding to $e$ has a static method or getter n amed $m$.
3375 \item The type \DYNAMIC{} otherwise.
3376 \end{itemize}
3477 3377
3478 Let $S$ be the superclass of the immediately enclosing class. The getter functio n (\ref{getters}) $m$ is looked up (\ref{getterAndSetterLookup}) in $S$ with re spect to the current library, and its body is executed with \THIS{} bound to th e current value of \THIS{}. The value of the getter invocation expression is t he result returned by the call to the getter function. 3378 If $i$ is a closurization, its static type is as described in section \ref{closu rization}.
3379
3380 Evaluation of a property extraction $i$ of the form $\SUPER.m$ proceeds as follo ws:
3381
3382 Let $S$ be the superclass of the immediately enclosing class. Let $f$ be the re sult of looking up method $m$ in $S$ with respect to the current library $L$. I f $f$ is a concrete method then $i$ evaluates to the closurization of $\SUPER.m$ with respect to superclass $S$(\ref{closurization}).
3383
3384 Otherwise, $i$ is a getter invocation and the getter function $m$ is looked up in $S$ with respect to $L$, and its body is executed with \THIS{} bound to the current value of \THIS{}. The value of $i$ is the result returned by the call to the getter function.
3479 3385
3480 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : 3386 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that :
3481 \begin{itemize} 3387 \begin{itemize}
3482 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. 3388 \item \code{im.isGetter} evaluates to \code{\TRUE{}}.
3483 \item \code{im.memberName} evaluates to \code{'m'}. 3389 \item \code{im.memberName} evaluates to \code{'m'}.
3484 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . 3390 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} .
3485 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 3391 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3486 \end{itemize} 3392 \end{itemize}
3487 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked with argu ment $im$, and the result of this invocation is the result of evaluating $i$. Ho wever, if the implementation found cannot be invoked with a single positional ar gument, the implementation of \code{noSuchMethod()} in class \code{Object} is i nvoked on \THIS{} with argument $im'$, where $im'$ is an instance of \code{Invoc ation} such that : 3393 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked with argu ment $im$, and the result of this invocation is the result of evaluating $i$. Ho wever, if the implementation found cannot be invoked with a single positional ar gument, the implementation of \code{noSuchMethod()} in class \code{Object} is i nvoked on \THIS{} with argument $im'$, where $im'$ is an instance of \code{Invoc ation} such that :
3488 \begin{itemize} 3394 \begin{itemize}
3489 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3395 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3490 \item \code{im.memberName} evaluates to \code{noSuchMethod}. 3396 \item \code{im.memberName} evaluates to \code{noSuchMethod}.
3491 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. 3397 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$.
3492 \item \code{im.namedArguments} evaluates to an empty immutable map. 3398 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3493 \end{itemize} 3399 \end{itemize}
3494 3400
3495 and the result of this latter invocation is the result of evaluating $i$. 3401 and the result of this latter invocation is the result of evaluating $i$.
3496 3402
3497 It is a static type warning if $S$ does not have a getter named $m$. The static type of $i$ is the declared return type of $S.m$, if $S.m$ exists; otherwise th e static type of $i$ is \DYNAMIC{}. 3403 It is a static type warning if $S$ does not have a method or getter named $m$. If $i$ is a getter invocation, the static type of $i$ is the declared return typ e of $S.m$, if $S.m$ exists and \DYNAMIC{} otherwise. If $i$ is a closurization , its static type is as described in section \ref{closurization}.
3498
3499 Evaluation of a getter invocation of the form $p.C.v$, where $p$ is a deferred p refix, proceeds as follows:
3500
3501 If $p$ has been successfully loaded, the assignment is evaluated exactly like th e invocation $K.v$, where $K$ denotes the top level member $C$ of the library re presented by $p$. Otherwise a \code{NoSuchMethodError} is thrown.
3502 3404
3503 3405
3504 Evaluation of a top-level getter invocation $i$ of the form $p.m$, where $p$ is a deferred prefix and $m$ is an identifier, proceeds as follows: 3406 \subsubsection{Closurization}
3407 \label{closurization}
3505 3408
3506 If $p$ has been successfully loaded, the invocation is evaluated exactly like th e invocation $w$, where $w$ denotes the top level member named $m$ of the librar y represented by $p$. Otherwise a \code{NoSuchMethodError} is thrown. 3409 The {\em closurization of $o.m$} is defined to be equivalent to:
3410
3411 \begin{itemize}
3412
3413 \item
3414 \begin{dartCode}
3415 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{
3416 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$
3417 \}
3418 \end{dartCode}
3419
3420 if $m$ has required parameters $r_1, \ldots, r_n$, and named parameters $p_1, \l dots, p_k$ with defaults $d_1, \ldots, d_k$.
3421 \item
3422 \begin{dartCode}
3423 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{
3424 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$;
3425 \}
3426 \end{dartCode}
3427
3428 if $m$ has required parameters $r_1, \ldots, r_n$, and optional positional param eters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
3429 \end{itemize}
3430
3431 where $u$ is a fresh final variable bound to $o$, except that:
3432 \begin{enumerate}
3433 \item Iff \code{identical($o_1, o_2$)} then \cd{$o_1.m$ == $o_2.m$}.
3434 \item The static type of the property extraction is the static type of function $T.m$, where $T$ is the static type of $e$, if $T.m$ is defined. Otherwise the s tatic type of $e.m$ is \DYNAMIC{}.
3435 \end{enumerate}
3436
3437 \commentary{
3438 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.
3439 }
3440 % local functions that have a closure extracted are always different
3441
3442 \rationale{
3443 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.
3444 }
3445
3446
3447
3448
3449 \commentary{Observations:
3450 \begin{enumerate}
3451 \item One cannot closurize a getter or a setter.
3452 \item One can tell whether one implemented a property via a method or via field/ getter, which means that one has to plan ahead as to what construct to use, and that choice is reflected in the interface of the class.
3453 \end{enumerate}
3454 }
3455
3456
3507 3457
3458 The closurization of $\SUPER{}.m$ with respect to superclass $S$ is defined to b e equivalent to:
3459
3460 \begin{itemize}
3461 %\item $(r_1, \ldots, r_n)\{\RETURN{}$ $o.m(r_1, \ldots, r_n);\}$ if $m$ has on ly required parameters $r_1, \ldots r_n$.
3462 %\item $(r_1, \ldots, r_n, rest)\{return$ $o.m(r_1, \ldots, r_n, rest);\}$ if $ m$ has required parameters $r_1, \ldots r_n$, and a rest parameter $rest$.
3463 %\item
3464 \item
3465 \begin{dartCode}
3466 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$\{
3467 \RETURN{} \SUPER{}$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k)$;
3468 \}
3469 \end{dartCode}
3470
3471 if $m$ has required parameters $r_1, \ldots, r_n$, and named parameters $p_1, \l dots, p_k$ with defaults $d_1, \ldots, d_k$.
3472 \item
3473 \begin{dartCode}
3474 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{
3475 \RETURN{} \SUPER{}$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$;
3476 \}
3477 \end{dartCode}
3478
3479 if $m$ has required parameters $r_1, \ldots, r_n$, and optional positional param eters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
3480 \end{itemize}
3481
3482 Except that:
3483 \begin{enumerate}
3484 \item iff \code{identical($o_1, o_2$)} then \cd{$o_1.m$ == $o_2.m$}.
3485 \item
3486 The static type of the property extraction is the static type of the method $S.m $, if $S.m$ is defined. Otherwise the static type of $\SUPER{}.m$ is \DYNAMIC{} .
3487 \end{enumerate}
3508 3488
3509 3489
3510 \subsection{ Assignment} 3490 \subsection{ Assignment}
3511 \label{assignment} 3491 \label{assignment}
3512 3492
3513 An assignment changes the value associated with a mutable variable or property. 3493 An assignment changes the value associated with a mutable variable or property.
3514 3494
3515 \begin{grammar} 3495 \begin{grammar}
3516 {\bf assignmentOperator:}`=' ; 3496 {\bf assignmentOperator:}`=' ;
3517 compoundAssignmentOperator 3497 compoundAssignmentOperator
(...skipping 21 matching lines...) Expand all
3539 Otherwise, if $d$ is the declaration of a static variable, static getter or stat ic setter in class $C$, then the assignment is equivalent to the assignment \cod e{$C.v$ = $e$}. 3519 Otherwise, if $d$ is the declaration of a static variable, static getter or stat ic setter in class $C$, then the assignment is equivalent to the assignment \cod e{$C.v$ = $e$}.
3540 3520
3541 Otherwise, If $a$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $a$ causes $ e$ to be evaluated, after which a \code{NoSuchMethodError} is thrown. 3521 Otherwise, If $a$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $a$ causes $ e$ to be evaluated, after which a \code{NoSuchMethodError} is thrown.
3542 3522
3543 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. 3523 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}.
3544 3524
3545 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$. 3525 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$.
3546 3526
3547 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$. 3527 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$.
3548 3528
3549 Evaluation of an assignment of the form $C.v$ \code{=} $e$ proceeds as follows:
3550
3551 If $C$ does not denote a class available in the current scope, the assignment is treated as an assignment $e_1.v= e$, where $e_1$ is the expression $C$. Otherw ise,
3552 the expression $e$ is evaluated to an object $o$.
3553 If
3554 %there is no class $C$ in the enclosing lexical scope of the assignment, or if
3555 $C$ does not declare, implicitly or explicitly, a setter $v=$, then a \code{NoSu chMethodError} is thrown. Otherwise, the setter $C.v=$ is invoked with its forma l parameter bound to $o$. The value of the assignment expression is $o$.
3556
3557 It is a static warning if
3558 % there is no class $C$ in the enclosing lexical scope of the assignment, or if
3559 $C$ does not declare, implicitly or explicitly, a setter $v=$.
3560
3561 %\commentary{As of this writing, implementations treat the above situation as a compile-time error.}
3562
3563 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 declared static type of $C.v$.
3564
3565 It is a static type warning if the static type of $e$ may not be assigned to the static type of $C.v$. The static type of the expression $C.v$ \code{=} $e$ is the static type of $e$.
3566
3567 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws: 3529 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws:
3568 3530
3569 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, and its body i s executed with its formal parameter bound to $o_2$ and \THIS{} bound to $o_1$. 3531 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$.
3570 3532
3571 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : 3533 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that :
3572 \begin{itemize} 3534 \begin{itemize}
3573 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. 3535 \item \code{im.isSetter} evaluates to \code{\TRUE{}}.
3574 \item \code{im.memberName} evaluates to \code{'v='}. 3536 \item \code{im.memberName} evaluates to \code{'v='}.
3575 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_2$]}. 3537 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_2$]}.
3576 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 3538 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3577 \end{itemize} 3539 \end{itemize}
3578 3540
3579 Then the method \code{noSuchMethod()} is looked up in $o_1$ and invoked with ar gument $im$. 3541 Then the method \code{noSuchMethod()} is looked up in $o_1$ and invoked with ar gument $im$.
3580 However, if the implementation found cannot be invoked with a single positional argument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $o_1$ with argument $im'$, where $im'$ is an instance of \code{Invoc ation} such that : 3542 However, if the implementation found cannot be invoked with a single positional argument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $o_1$ with argument $im'$, where $im'$ is an instance of \code{Invoc ation} such that :
3581 \begin{itemize} 3543 \begin{itemize}
3582 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3544 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3583 \item \code{im.memberName} evaluates to \code{noSuchMethod}. 3545 \item \code{im.memberName} evaluates to \code{noSuchMethod}.
3584 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. 3546 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$.
3585 \item \code{im.namedArguments} evaluates to an empty immutable map. 3547 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3586 \end{itemize} 3548 \end{itemize}
3587 3549
3588 The value of the assignment expression is $o_2$ irrespective of whether setter l ookup has failed or succeeded. 3550 The value of the assignment expression is $o_2$ irrespective of whether setter l ookup has failed or succeeded.
3589 3551
3590 Evaluation of an assignment of the form $p.v \code{=} e$, where $p$ is a deferre d prefix, proceeds as follows:
3591
3592 If $p$ has been successfully loaded, the assignment is evaluated exactly like th e assignment $w \code{=} e$, where $w$ denotes the top level member named $v$ of the library represented by $p$. Otherwise, $e$ is evaluated and then a \code{No SuchMethodError} is thrown.
3593
3594 Evaluation of an assignment of the form $p.C.v \code{=} e$, where $p$ is a defer red prefix, proceeds as follows:
3595
3596 If $p$ has been successfully loaded, the assignment is evaluated exactly like th e assignment $K.v = e$, where $K$ denotes the top level member $C$ of the librar y represented by $p$. Otherwise $e$ is evaluated and then a \code{NoSuchMethodEr ror} is thrown.
3597
3598 In checked mode, it is a dynamic type error if $o_2$ is not \NULL{} and the inte rface of the class of $o_2$ is not a subtype of the actual type of $e_1.v$. 3552 In checked mode, it is a dynamic type error if $o_2$ is not \NULL{} and the inte rface of the class of $o_2$ is not a subtype of the actual type of $e_1.v$.
3599 3553
3600 Let $T$ be the static type of $e_1$. It is a static type warning if $T$ does not have an accessible instance setter named $v=$ unless $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the consta nt \code{@proxy} defined in \code{dart:core}. It is a static type warning if the static type of $e_2$ may not be assigned to $T$. The static type of the expre ssion $e_1v$ \code{=} $e_2$ is the static type of $e_2$. 3554 Let $T$ be the static type of $e_1$. It is a static type warning if $T$ does not have an accessible instance setter named $v=$ unless either:
3555 \begin{itemize}
3556 \item $T$ or a superinterface of $T$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \code{dart:core}. Or
3557 \item $T$ is \code{Type}, $e_1$ is a constant type literal and the class corresp onding to $e_1$ has a static setter named $v=$.
3558 \end{itemize}
3559
3560
3561
3562 It is a static type warning if the static type of $e_2$ may not be assigned to $ T$. The static type of the expression $e_1v$ \code{=} $e_2$ is the static type of $e_2$.
3601 3563
3602 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$. 3564 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$.
3603 3565
3604 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map. 3566 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map.
3605 3567
3606 It is as 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 variabl e initializer and there is neither a local variable declaration with name $v$ n or setter declaration with name $v=$ in the lexical scope enclosing the assignme nt. 3568 It is as 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 variabl e initializer and there is neither a local variable declaration with name $v$ n or setter declaration with name $v=$ in the lexical scope enclosing the assignme nt.
3607 3569
3570 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 `.'.
3571
3608 3572
3609 3573
3610 \subsubsection{Compound Assignment} 3574 \subsubsection{Compound Assignment}
3611 \label{compoundAssignment} 3575 \label{compoundAssignment}
3612 3576
3613 A compound assignment of the form $v$ $op\code{=} e$ is equivalent to $v \code{= } v$ $op$ $e$. A compound assignment of the form $C.v$ $op \code{=} e$ is equiva lent to $C.v \code{=} C.v$ $op$ $e$. A compound assignment of the form $e_1.v$ $ op = e_2$ is equivalent to \code{((x) $=>$ x.v = x.v $op$ $e_2$)($e_1$)} where $ x$ is a variable that is not used in $e_2$. A compound assignment of the form $ e_1[e_2]$ $op\code{=} e_3$ is equivalent to 3577 A compound assignment of the form $v$ $op\code{=} e$ is equivalent to $v \code{= } v$ $op$ $e$. A compound assignment of the form $C.v$ $op \code{=} e$ is equiva lent to $C.v \code{=} C.v$ $op$ $e$. A compound assignment of the form $e_1.v$ $ op = e_2$ is equivalent to \code{((x) $=>$ x.v = x.v $op$ $e_2$)($e_1$)} where $ x$ is a variable that is not used in $e_2$. A compound assignment of the form $ e_1[e_2]$ $op\code{=} e_3$ is equivalent to
3614 \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$. A compound assignment of the form $p.v$ $o p\code{=} e$, where $p$ is a deferred prefix, is equivalent to $p.v \code{=} p. v$ $op$ $e$. A compound assignment of the form $p.C.v$ $op\code{=} e$, where $p$ is a deferred prefix, is equivalent to $p.C.v \code{=} p.C.v$ $op$ $e$. 3578 \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$.
3615 3579
3616 3580
3617 \begin{grammar} 3581 \begin{grammar}
3618 {\bf compoundAssignmentOperator:}`*='; 3582 {\bf compoundAssignmentOperator:}`*=';
3619 `/='; 3583 `/=';
3620 `\~{}/='; 3584 `\~{}/=';
3621 `\%='; 3585 `\%=';
3622 `+='; 3586 `+=';
3623 `-='; 3587 `-=';
3624 `{\escapegrammar \lt \lt}='; 3588 `{\escapegrammar \lt \lt}=';
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
4013 \item An identifier. 3977 \item An identifier.
4014 \item An invocation of a getter (\ref{getters}) or list access operator on an ex pression $e$. 3978 \item An invocation of a getter (\ref{getters}) or list access operator on an ex pression $e$.
4015 \item An invocation of a getter or list access operator on \SUPER{}. 3979 \item An invocation of a getter or list access operator on \SUPER{}.
4016 \end{itemize} 3980 \end{itemize}
4017 3981
4018 3982
4019 An assignable expression of the form $id$ is evaluated as an identifier expressi on (\ref{identifierReference}). 3983 An assignable expression of the form $id$ is evaluated as an identifier expressi on (\ref{identifierReference}).
4020 3984
4021 %An assignable expression of the form $e.id(a_1, \ldots, a_n)$ is evaluated as a method invocation (\ref{methodInvocation}). 3985 %An assignable expression of the form $e.id(a_1, \ldots, a_n)$ is evaluated as a method invocation (\ref{methodInvocation}).
4022 3986
4023 An assignable expression of the form $e.id$ is evaluated as a getter invocation (\ref{getterInvocation}). 3987 An assignable expression of the form $e.id$ is evaluated as a property extractio n (\ref{propertyExtraction}).
4024 3988
4025 An assignable expression of the form \code{$e_1$[$e_2$]} is evaluated as a metho d invocation of the operator method \code{[]} on $e_1$ with argument $e_2$. 3989 An assignable expression of the form \code{$e_1$[$e_2$]} is evaluated as a metho d invocation of the operator method \code{[]} on $e_1$ with argument $e_2$.
4026 3990
4027 An assignable expression of the form \code{\SUPER{}.id} is evaluated as a gette r invocation. 3991 An assignable expression of the form \code{\SUPER{}.id} is evaluated as a prope rty extraction.
4028 3992
4029 An assignable expression of the form \code{\SUPER{}[$e_2$]} is equivalent to the method invocation \code{\SUPER{}.[]($e_2$)}. 3993 An assignable expression of the form \code{\SUPER{}[$e_2$]} is equivalent to the method invocation \code{\SUPER{}.[]($e_2$)}.
4030 3994
4031 \subsection{ Identifier Reference} 3995 \subsection{ Identifier Reference}
4032 \label{identifierReference} 3996 \label{identifierReference}
4033 3997
4034 An {\em identifier expression} consists of a single identifier; it provides acce ss to an object via an unqualified name. 3998 An {\em identifier expression} consists of a single identifier; it provides acce ss to an object via an unqualified name.
4035 3999
4036 \begin{grammar} 4000 \begin{grammar}
4037 {\bf identifier:} 4001 {\bf identifier:}
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4095 Built-in identifiers are identifiers that are used as keywords in Dart, but are not reserved words in Javascript. To minimize incompatibilities when porting Jav ascript code to Dart, we do not make these into reserved words. A built-in ident ifier may not be used to name a class or type. In other words, they are treated as reserved words when used as types. This eliminates many confusing situations without causing compatibility problems. After all, a Javascript program has no type declarations or annotations so no clash can occur. Furthermore, types shou ld begin with an uppercase letter (see the appendix) and so no clash should occu r in any Dart user program anyway. 4059 Built-in identifiers are identifiers that are used as keywords in Dart, but are not reserved words in Javascript. To minimize incompatibilities when porting Jav ascript code to Dart, we do not make these into reserved words. A built-in ident ifier may not be used to name a class or type. In other words, they are treated as reserved words when used as types. This eliminates many confusing situations without causing compatibility problems. After all, a Javascript program has no type declarations or annotations so no clash can occur. Furthermore, types shou ld begin with an uppercase letter (see the appendix) and so no clash should occu r in any Dart user program anyway.
4096 } 4060 }
4097 4061
4098 Evaluation of an identifier expression $e$ of the form $id$ proceeds as follows: 4062 Evaluation of an identifier expression $e$ of the form $id$ proceeds as follows:
4099 4063
4100 4064
4101 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. 4065 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.
4102 %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. 4066 %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.
4103 4067
4104 \begin{itemize} 4068 \begin{itemize}
4105 \item If $d$ is a class or type alias $T$, the value of $e$ is an instance of cl ass \code{Type} reifying $T$. 4069 \item if $d$ is a prefix $p$, a compile-time error occurs unless the token immed iately following $d$ is \code{'.'}.
4070 \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$.
4106 \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. 4071 \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.
4107 4072
4108 %\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}.)} 4073 %\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}.)}
4109 %\item If $d$ is a library variable then: 4074 %\item If $d$ is a library variable then:
4110 % \begin{itemize} 4075 % \begin{itemize}
4111 % \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$. 4076 % \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$.
4112 \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$. 4077 \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$.
4113 % Otherwise 4078 % Otherwise
4114 % \item $e$ evaluates to the current binding of $id$. 4079 % \item $e$ evaluates to the current binding of $id$.
4115 % \end{itemize} 4080 % \end{itemize}
4116 \item If $d$ is a local variable or formal parameter then $e$ evaluates to the c urrent binding of $id$. 4081 \item If $d$ is a local variable or formal parameter then $e$ evaluates to the c urrent binding of $id$.
4117 %\item If $d$ is a library variable, local variable, or formal parameter, then $ e$ evaluates to the current binding of $id$. \commentary{This case also applies if d is a library or local function declaration, as these are equivalent to func tion-valued variable declarations.} 4082 %\item If $d$ is a library variable, local variable, or formal parameter, then $ e$ evaluates to the current binding of $id$. \commentary{This case also applies if d is a library or local function declaration, as these are equivalent to func tion-valued variable declarations.}
4118 \item If $d$ is a static method, top-level function or local function then $e$ e valuates to the function defined by $d$. 4083 \item If $d$ is a static method, top-level function or local function then $e$ e valuates to the function defined by $d$.
4119 \item If $d$ is the declaration of a static variable, static getter or static se tter declared in class $C$, then $e$ is equivalent to the getter invocation (\re f{getterInvocation}) $C.id$. 4084 \item If $d$ is the declaration of a static variable, static getter or static se tter declared in class $C$, then $e$ is equivalent to the property extraction (\ ref{propertyExtraction}) $C.id$.
4120 \item If $d$ is the declaration of a library variable, top-level getter or top-l evel setter, then $e$ is equivalent to the getter invocation $id$. 4085 \item If $d$ is the declaration of a library variable, top-level getter or top-l evel setter, then $e$ is equivalent to the top level getter invocation (\ref{top LevelGetterInvocation}) $id$.
4121 \item Otherwise, if $e$ occurs inside a top level or static function (be it func tion, method, getter, or setter) or variable initializer, evaluation of $e$ cau ses a \code{NoSuchMethod} to be thrown. 4086 \item Otherwise, if $e$ occurs inside a top level or static function (be it func tion, method, getter, or setter) or variable initializer, evaluation of $e$ cau ses a \code{NoSuchMethod} to be thrown.
4122 \item Otherwise, $e$ is equivalent to the property extraction (\ref{propertyExtr action}) \THIS{}.$id$. 4087 \item Otherwise, $e$ is equivalent to the property extraction (\ref{propertyExtr action}) \THIS{}.$id$.
4123 % This implies that referring to an undefined static getter by simple name is an error, whereas doing so by qualified name is only a warning. Same with assignme nts. Revise? 4088 % This implies that referring to an undefined static getter by simple name is an error, whereas doing so by qualified name is only a warning. Same with assignme nts. Revise?
4124 \end{itemize} 4089 \end{itemize}
4125 4090
4126 The static type of $e$ is determined as follows: 4091 The static type of $e$ is determined as follows:
4127 4092
4128 \begin{itemize} 4093 \begin{itemize}
4129 \item If $d$ is a class, type alias or type parameter the static type of $e$ is \code{Type}. 4094 \item If $d$ is a class, type alias or type parameter the static type of $e$ is \code{Type}.
4130 \item If $d$ is a local variable or formal parameter the static type of $e$ is t he type of the variable $id$, unless $id$ is known to have some type $T$, in whi ch case the static type of $e$ is $T$, provided that $T$ is more specific than a ny other type $S$ such that $v$ is known to have type $S$. 4095 \item If $d$ is a local variable or formal parameter the static type of $e$ is t he type of the variable $id$, unless $id$ is known to have some type $T$, in whi ch case the static type of $e$ is $T$, provided that $T$ is more specific than a ny other type $S$ such that $v$ is known to have type $S$.
4131 \item If $d$ is a static method, top-level function or local function the static type of $e$ is the function type defined by $d$. 4096 \item If $d$ is a static method, top-level function or local function the static type of $e$ is the function type defined by $d$.
4132 \item If $d$ is the declaration of a static variable, static getter or static se tter declared in class $C$, the static type of $e$ is the static type of the get ter invocation (\ref{getterInvocation}) $C.id$. 4097 \item If $d$ is the declaration of a static variable, static getter or static se tter declared in class $C$, the static type of $e$ is the static type of the get ter invocation (\ref{propertyExtraction}) $C.id$.
4133 \item If $d$ is the declaration of a library variable, top-level getter or top-l evel setter, the static type of $e$ is the static type of the getter invocation $id$. 4098 \item If $d$ is the declaration of a library variable, top-level getter or top-l evel setter, the static type of $e$ is the static type of the top level getter invocation $id$.
4134 \item Otherwise, if $e$ occurs inside a top level or static function (be it func tion, method, getter, or setter) or variable initializer, the static type of $e $ is \DYNAMIC{}. 4099 \item Otherwise, if $e$ occurs inside a top level or static function (be it func tion, method, getter, or setter) or variable initializer, the static type of $e $ is \DYNAMIC{}.
4135 \item Otherwise, the static type of $e$ is the type of the property extraction ( \ref{propertyExtraction}) \THIS{}.$id$. 4100 \item Otherwise, the static type of $e$ is the type of the property extraction ( \ref{propertyExtraction}) \THIS{}.$id$.
4136 \end{itemize} 4101 \end{itemize}
4137 4102
4138 \commentary{Note that if one declares a setter, we bind to the corresponding ge tter even if it does not exist.} 4103 \commentary{Note that if one declares a setter, we bind to the corresponding ge tter even if it does not exist.}
4139 4104
4140 \rationale{ 4105 \rationale{
4141 This prevents situations where one uses uncorrelated setters and getters. The i ntent is to prevent errors when a getter in a surrounding scope is used acciden tally. 4106 This prevents situations where one uses uncorrelated setters and getters. The i ntent is to prevent errors when a getter in a surrounding scope is used acciden tally.
4142 } 4107 }
4143 4108
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
5122 5087
5123 5088
5124 The {\em current library} is the library currently being compiled. The import mo difies the namespace of the current library in a manner that is determined by t he imported library and by the optional elements of the import. 5089 The {\em current library} is the library currently being compiled. The import mo difies the namespace of the current library in a manner that is determined by t he imported library and by the optional elements of the import.
5125 5090
5126 An immediate import directive $I$ may optionally include a prefix clause of the form \AS{} \code{Id} used to prefix names imported by $I$. A deferred import mus t include a prefix clause or a compile time error occurs. It is a compile-time e rror if a prefix used in a deferred import is used in another import clause. 5091 An immediate import directive $I$ may optionally include a prefix clause of the form \AS{} \code{Id} used to prefix names imported by $I$. A deferred import mus t include a prefix clause or a compile time error occurs. It is a compile-time e rror if a prefix used in a deferred import is used in another import clause.
5127 5092
5128 An import directive $I$ may optionally include a namespace combinator clauses us ed to restrict the set of names imported by $I$. Currently, two namespace combin ators are supported: \HIDE{} and \SHOW{}. 5093 An import directive $I$ may optionally include a namespace combinator clauses us ed to restrict the set of names imported by $I$. Currently, two namespace combin ators are supported: \HIDE{} and \SHOW{}.
5129 5094
5130 Let $I$ be an import directive that refers to a URI via the string $s_1$. Evalua tion of $I$ proceeds as follows: 5095 Let $I$ be an import directive that refers to a URI via the string $s_1$. Evalua tion of $I$ proceeds as follows:
5131 5096
5132 If $I$ is a deferred import, no evaluation takes place. Instead, the following n ames are added to the scope of $L$: 5097 If $I$ is a deferred import, no evaluation takes place. Instead, an mapping the name of the prefix, $p$ to a {\em deferred prefix object} is added to the scope of $L$.
5098 The deferred prefix object has the following methods:
5099
5133 \begin{itemize} 5100 \begin{itemize}
5134 \item 5101 \item \code{loadLibrary}. This method returns a future $f$. When called, the met hod causes an immediate import $IÕ$ to be executed at some future time, where $I Õ$ is is derived from $I$ by eliding the word \DEFERRED{} and adding a \HIDE{} \ code{loadLibrary} combinator clause. When $IÕ$ executes without error, $f$ comp letes successfully. If $IÕ$ executes without error, we say that the call to \cod e{loadLibrary} has succeeded, otherwise we say the call has failed.
5135 The name of the prefix, $p$ denoting a deferred prefix declaration. 5102 \item For every top level function $f$ named $id$ in $L$, a corresponding metho d named $id$ with the same signature as $f$. Calling the method results in a run time error.
5136 \item 5103 \item For every top level getter $g$ named $id$ in $L$, a corresponding getter n amed $id$ with the same signature as $g$. Calling the method results in a runti me error.
5137 The name \code{$p$.loadLibrary}, denoting a top level function with no arguments , whose semantics are described below. 5104 \item For every top level setter $s$ named $id$ in $L$, a corresponding setter n amed $id$ with the same signature as $s$. Calling the method results in a runti me error.
5105 \item For every type $T$ named $id$ in $L$, a corresponding getter named $id$ wi th return type \code{Type}. Calling the method results in a runtime error.
5138 \end{itemize} 5106 \end{itemize}
5139
5140 A deferred prefix $p$ may be loaded explicitly via the function call \code{$p$.l oadLibrary}, which returns a future $f$. The effect of the call is to cause an i mmediate import $IÕ$ to be executed at some future time, where $IÕ$ is is derive d from $I$ by eliding the word \DEFERRED{} and adding a \HIDE{} \code{loadLibrar y} combinator clause. When $IÕ$ executes without error, $f$ completes successfu lly. If $IÕ$ executes without error, we say that the call to \code{$p$.loadLibra ry} has succeeded, otherwise we say the call has failed.
5141 5107
5142 After a call succeeds, the names $p$ and \code{$p$.loadLibrary} remain in the to p-level scope of $L$, and so it is possible to call \code{loadLibrary} again. If a call fails, nothing happens, and one again has the option to call \code{loadL ibrary} again. Whether a repeated call to \code{loadLibrary} succeeds will vary as described below. 5108 After a call succeeds, the name $p$ is mapped to a non-deferred prefix object as described below. In addition, the prefix object also supports the \code{loadLib rary} method, and so it is possible to call \code{loadLibrary} again. If a call fails, nothing happens, and one again has the option to call \code{loadLibrary} again. Whether a repeated call to \code{loadLibrary} succeeds will vary as descr ibed below.
5143 5109
5144 The effect of a repeated call to \code{$p$.loadLibrary} is as follows: 5110 The effect of a repeated call to \code{$p$.loadLibrary} is as follows:
5145 \begin{itemize} 5111 \begin{itemize}
5146 \item 5112 \item
5147 If another call to \code{$p$.loadLibrary} has already succeeded, the repeated ca ll also succeeds. 5113 If another call to \code{$p$.loadLibrary} has already succeeded, the repeated ca ll also succeeds.
5148 Otherwise, 5114 Otherwise,
5149 \item 5115 \item
5150 If another call to to \code{$p$.loadLibrary} has failed: 5116 If another call to to \code{$p$.loadLibrary} has failed:
5151 \begin{itemize} 5117 \begin{itemize}
5152 \item 5118 \item
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5184 5150
5185 \item If $C_i$ is of the form 5151 \item If $C_i$ is of the form
5186 5152
5187 \code{\HIDE{} $id_1, \ldots, id_k$} 5153 \code{\HIDE{} $id_1, \ldots, id_k$}
5188 5154
5189 then let $NS_i = \HIDE{}([id_1, \ldots, id_k], NS_{i-1}$) 5155 then let $NS_i = \HIDE{}([id_1, \ldots, id_k], NS_{i-1}$)
5190 5156
5191 where $hide(l, n)$ takes a list of identfiers $l$ and a namespace $n$, and produ ces a namespace that is identical to $n$ except that for each name $k$ in $l$, $ k$ and $k=$ are undefined. 5157 where $hide(l, n)$ takes a list of identfiers $l$ and a namespace $n$, and produ ces a namespace that is identical to $n$ except that for each name $k$ in $l$, $ k$ and $k=$ are undefined.
5192 \end{itemize} 5158 \end{itemize}
5193 5159
5194 Next, if $I$ includes a prefix clause of the form \AS{} $p$, let $NS = prefix(p , NS_n)$ where $prefix(id, n)$, takes an identifier $id$ and produces a namespac e that has, for each entry mapping key $k$ to declaration $d$ in $n$, an entry mapping $id.k$ to $d$. Otherwise, let $NS = NS_n$. 5160 Next, if $I$ includes a prefix clause of the form \AS{} $p$, let $NS = NS_n \cu p \{p: prefixObject(NS_n)\}$ where $prefixObject(NS_n)$ is a {\em prefix object} for the namespace $NS_n$, which is an object that has the following members:
5161
5162 \begin{itemize}
5163 \item For every top level function $f$ named $id$ in $NS_n$, a corresponding me thod with the same name and signature as $f$ that forwards (\ref{functionDeclar ations}) to $f$.
5164 \item For every top level getter with the same name and signature as $g$ named $id$ in $NS_n$, a corresponding getter that forwards to $g$.
5165 \item For every top level setter $s$ with the same name and signature as named $id$ in $NS_n$, a corresponding setter that forwards to $s$.
5166 \item For every type $T$ named $id$ in $NS_n$, a corresponding getter named $id$ with return type \code{Type}, that, when invoked, returns the type object for $ T$.
5167 \end{itemize}
5168
5169 Otherwise, let $NS = NS_n$.
5195 It is a compile-time error if the current library declares a top-level member na med $p$. 5170 It is a compile-time error if the current library declares a top-level member na med $p$.
5196 5171
5197 % This is problematic, because it implies that p.T would be available even in a scope that declared p. We really need to think of p as a single object with prop erties p.T etc., except it isn't really that 5172 % This is problematic, because it implies that p.T would be available even in a scope that declared p. We really need to think of p as a single object with prop erties p.T etc., except it isn't really that
5198 % either. After all, p isn't actually available as a stand alone name. 5173 % either. After all, p isn't actually available as a stand alone name.
5199 5174
5200 Then, for each entry mapping key $k$ to declaration $d$ in $NS$, $d$ is made av ailable in the top level scope of $L$ under the name $k$ unless either: 5175 Then, for each entry mapping key $k$ to declaration $d$ in $NS$, $d$ is made av ailable in the top level scope of $L$ under the name $k$ unless either:
5201 \begin{itemize} 5176 \begin{itemize}
5202 \item 5177 \item
5203 a top-level declaration with the name $k$ exists in $L$, OR 5178 a top-level declaration with the name $k$ exists in $L$, OR
5204 \item a prefix clause of the form \AS{} $k$ is used in $L$. 5179 \item a prefix clause of the form \AS{} $k$ is used in $L$.
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
6084 \item The names of compile time constant variables never use lower case letters. If they consist of multiple words, those words are separated by underscores. Ex amples: PI, I\_AM\_A\_CONSTANT. 6059 \item The names of compile time constant variables never use lower case letters. If they consist of multiple words, those words are separated by underscores. Ex amples: PI, I\_AM\_A\_CONSTANT.
6085 \item The names of functions (including getters, setters, methods and local or l ibrary functions) and non-constant variables begin with a lowercase letter. If t he name consists of multiple words, each word (except the first) begins with an uppercase letter. No other uppercase letters are used. Examples: camlCase, dar t4TheWorld 6060 \item The names of functions (including getters, setters, methods and local or l ibrary functions) and non-constant variables begin with a lowercase letter. If t he name consists of multiple words, each word (except the first) begins with an uppercase letter. No other uppercase letters are used. Examples: camlCase, dar t4TheWorld
6086 \item The names of types (including classes and type aliases) begin with an uppe r case letter. If the name consists of multiple words, each word begins with an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D art4TheWorld. 6061 \item The names of types (including classes and type aliases) begin with an uppe r case letter. If the name consists of multiple words, each word begins with an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D art4TheWorld.
6087 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E. 6062 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E.
6088 \item The names of libraries or library prefixes never use upper case letters. I f they consist of multiple words, those words are separated by underscores. Exam ple: my\_favorite\_library. 6063 \item The names of libraries or library prefixes never use upper case letters. I f they consist of multiple words, those words are separated by underscores. Exam ple: my\_favorite\_library.
6089 \end{itemize} 6064 \end{itemize}
6090 } 6065 }
6091 6066
6092 6067
6093 \end{document} 6068 \end{document}
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