OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3149 | 3154 |
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$. | 3155 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 | 3156 |
3152 \subsubsection{ Unqualified Invocation} | 3157 \subsubsection{ Unqualified Invocation} |
3153 \label{unqualifiedInvocation} | 3158 \label{unqualifiedInvocation} |
3154 | 3159 |
3155 An unqualified function invocation $i$ has the form | 3160 An unqualified function invocation $i$ has the form |
3156 | 3161 |
3157 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, | 3162 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, |
3158 | 3163 |
3159 where $id$ is an identifier or an identifier qualified with a library prefix. | 3164 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 | 3165 |
3169 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the innermost such declaration. Then: | 3166 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the innermost such declaration. Then: |
3170 \begin{itemize} | 3167 \begin{itemize} |
3171 \item | 3168 \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}). | 3169 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 | 3170 \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}) $. | 3171 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}) $. | 3172 \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} | 3173 \end{itemize} |
3177 | 3174 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3222 \subsection{ Method Invocation} | 3219 \subsection{ Method Invocation} |
3223 \label{methodInvocation} | 3220 \label{methodInvocation} |
3224 | 3221 |
3225 Method invocation can take several forms as specified below. | 3222 Method invocation can take several forms as specified below. |
3226 | 3223 |
3227 \subsubsection{Ordinary Invocation} | 3224 \subsubsection{Ordinary Invocation} |
3228 \label{ordinaryInvocation} | 3225 \label{ordinaryInvocation} |
3229 | 3226 |
3230 An ordinary method invocation $i$ has the form | 3227 An ordinary method invocation $i$ has the form |
3231 | 3228 |
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. | 3229 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. |
3233 | 3230 |
3234 Method invocation involves method lookup, defined next. | 3231 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$. | 3232 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 | 3233 |
3237 The result of a lookup of method $m$ in class $C$ with respect to library $L$ i s: | 3234 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. | 3235 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 | 3236 |
3240 \rationale { | 3237 \rationale { |
3241 The motivation for skipping abstract members during lookup is largely to allow s moother mixin composition. | 3238 The motivation for skipping abstract members during lookup is largely to allow s moother mixin composition. |
3242 } | 3239 } |
3243 | 3240 |
3244 Evaluation of an ordinary method invocation $i$ of the form | 3241 Evaluation of an ordinary method invocation $i$ of the form |
3245 | 3242 |
3246 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ | 3243 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ |
3247 | 3244 |
3248 proceeds as follows: | 3245 proceeds as follows: |
3249 | 3246 |
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$. | 3247 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$. |
3251 | 3248 |
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$. | 3249 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 | 3250 |
3254 \commentary{ | 3251 \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. | 3252 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 } | 3253 } |
3257 | 3254 |
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. | 3255 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 | 3256 |
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. | 3257 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 | 3258 |
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 | 3259 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$. |
3260 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. | |
3261 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}\}$. | 3262 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 | 3263 |
3265 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : | 3264 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} | 3265 \begin{itemize} |
3267 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3266 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3268 \item \code{im.memberName} evaluates to \code{'m'}. | 3267 \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$]}. | 3268 \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}$\}}. | 3269 \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} | 3270 \end{itemize} |
3272 | 3271 |
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 : | 3272 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 : |
3274 \begin{itemize} | 3273 \begin{itemize} |
3275 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3274 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3276 \item \code{im.memberName} evaluates to \code{noSuchMethod'}. | 3275 \item \code{im.memberName} evaluates to \code{noSuchMethod'}. |
3277 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 3276 \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. | 3277 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3279 \end{itemize} | 3278 \end{itemize} |
3280 | 3279 |
3281 and the result of the latter invocation is the result of evaluating $i$. | 3280 and the result of the latter invocation is the result of evaluating $i$. |
3282 | 3281 |
3283 \rationale { | 3282 \rationale { |
3284 It is possible to bring about such a situation by overriding \code{noSuchMethod( )} with the wrong number of arguments:} | 3283 It is possible to bring about such a situation by overriding \code{noSuchMethod( )} with the wrong number of arguments:} |
3285 | 3284 |
3286 \begin{code} | 3285 \begin{code} |
3287 \CLASS{} Perverse \{ | 3286 \CLASS{} Perverse \{ |
3288 noSuchMethod(x,y) =$>$ x + y; | 3287 noSuchMethod(x,y) =$>$ x + y; |
3289 \} | 3288 \} |
3290 | 3289 |
3291 \NEW{} Perverse.unknownMethod(); | 3290 \NEW{} Perverse.unknownMethod(); |
3292 \end{code} | 3291 \end{code} |
3293 | 3292 |
3294 \commentary{Notice that the wording carefully avoids re-evaluating the receiver $o$ and the arguments $a_i$. } | 3293 \commentary{Notice that the wording carefully avoids re-evaluating the receiver $o$ and the arguments $a_i$. } |
3295 | 3294 |
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$. | 3295 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$. | 3296 \begin{itemize} |
3297 \item | |
3298 $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 | |
3299 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static getter named $m$. | |
3300 \end{itemize} | |
3298 | 3301 |
3302 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 | 3303 |
3300 | 3304 It is a compile-time error to invoke any of the methods of class \cd{object} on a prefix object (\ref{imports}) or a constant type literal that is not immediate ly enclosed in parentheses. |
Lasse Reichstein Nielsen
2014/07/17 13:42:45
Works for prefix objects, but "enclosed in parenth
gbracha
2014/07/17 21:42:28
Fair enough. I'll reformulate as you suggest.
| |
3301 %\subsubsection{This Invocation} | |
3302 % Maybe this has no significance the way the language is set up? | |
3303 | 3305 |
3304 | 3306 |
3305 \subsubsection{Cascaded Invocations} | 3307 \subsubsection{Cascaded Invocations} |
3306 \label{cascadedInvocations} | 3308 \label{cascadedInvocations} |
3307 | 3309 |
3308 A {\em cascaded method invocation} has the form {\em e..suffix} | 3310 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. | 3311 where $e$ is an expression and {\em suffix} is a sequence of operator, method, g etter or setter invocations. |
3310 | 3312 |
3311 \begin{grammar} | 3313 \begin{grammar} |
3312 {\bf cascadeSection:} | 3314 {\bf cascadeSection:} |
3313 `{\escapegrammar ..}' (cascadeSelector arguments*) (assignableSelector arg uments*)* (assignmentOperator expressionWithoutCascade)? | 3315 `{\escapegrammar ..}' (cascadeSelector arguments*) (assignableSelector arg uments*)* (assignmentOperator expressionWithoutCascade)? |
3314 . | 3316 . |
3315 | 3317 |
3316 {\bf cascadeSelector:}`[' expression `]'; | 3318 {\bf cascadeSelector:}`[' expression `]'; |
3317 identifier | 3319 identifier |
3318 . | 3320 . |
3319 \end{grammar} | 3321 \end{grammar} |
3320 | 3322 |
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$)}. | 3323 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 | 3324 |
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} | 3325 \subsubsection{Super Invocation} |
3364 \label{superInvocation} | 3326 \label{superInvocation} |
3365 | 3327 |
3366 A super method invocation $i$ has the form | 3328 A super method invocation $i$ has the form |
3367 | 3329 |
3368 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. | 3330 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. |
3369 | 3331 |
3370 Evaluation of $i$ proceeds as follows: | 3332 Evaluation of $i$ proceeds as follows: |
3371 | 3333 |
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$. | 3334 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 Loading... | |
3384 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3346 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3385 \item \code{im.memberName} evaluates to \code{'m'}. | 3347 \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$]}. | 3348 \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}$\}}. | 3349 \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} | 3350 \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 : | 3351 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} | 3352 \begin{itemize} |
3391 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3353 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3392 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 3354 \item \code{im.memberName} evaluates to \code{noSuchMethod}. |
3393 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 3355 \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. | 3356 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3395 \end{itemize} | 3357 \end{itemize} |
3396 | 3358 |
3397 and the result of this latter invocation is the result of evaluating $i$. | 3359 and the result of this latter invocation is the result of evaluating $i$. |
3398 | 3360 |
3399 | 3361 |
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. | 3362 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 | 3363 |
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$. | 3364 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" | 3365 % 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$. | 3366 %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$. |
(...skipping 10 matching lines...) Expand all Loading... | |
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. | 3377 \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 } | 3378 } |
3417 | 3379 |
3418 | 3380 |
3419 \subsection{ Getter and Setter Lookup} | 3381 \subsection{ Getter and Setter Lookup} |
3420 \label{getterAndSetterLookup} | 3382 \label{getterAndSetterLookup} |
3421 | 3383 |
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$. | 3384 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$. |
3423 | 3385 |
3424 The result of a lookup of a getter (respectively setter) $m$ in class $C$ with respect to library $L$ is: | 3386 The result of a lookup of a getter (respectively setter) $m$ in class $C$ with respect to library $L$ is: |
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. | 3387 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. |
Lasse Reichstein Nielsen
2014/07/17 13:42:45
I could be wrong, but I don't think a method intro
gbracha
2014/07/17 21:42:28
See reply to comment below. However, I don't think
Lasse Reichstein Nielsen
2014/07/18 13:49:08
Ack, good - but subtle - point.
| |
3426 | 3388 |
3427 \rationale { | 3389 \rationale { |
3428 The motivation for skipping abstract members during lookup is largely to allow s moother mixin composition. | 3390 The motivation for skipping abstract members during lookup is largely to allow s moother mixin composition. |
3429 } | 3391 } |
3430 | 3392 |
3431 \subsection{ Getter Invocation} | 3393 \subsection{ Getter Invocation} |
3432 \label{getterInvocation} | 3394 \label{getterInvocation} |
3433 | 3395 |
3434 A getter invocation provides access to the value of a property. | 3396 A getter invocation provides access to the value of a property. |
3435 | 3397 |
3436 Evaluation of a getter invocation $i$ of the form $e.m$ proceeds as follows: | 3398 Evaluation of a getter invocation $i$ of the form $e.m$ proceeds as follows: |
3437 | 3399 |
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. | 3400 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. If $o$ is an instance of \code{Type} but $e$ is not a constant type literal, then if $m$ is a getter that forwards (\ref{functi onDeclarations}) to a static getter, getter lookup fails. Otherwise, the body o f $m$ 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 | 3401 |
3440 | 3402 |
3441 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 3403 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : |
Lasse Reichstein Nielsen
2014/07/17 13:42:45
At this point, shouldn't we try to see if the obje
gbracha
2014/07/17 21:42:28
Both this and the comment above allude to another
Lasse Reichstein Nielsen
2014/07/18 13:49:08
Sounds good. I often find it a little hard to figu
| |
3442 \begin{itemize} | 3404 \begin{itemize} |
3443 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. | 3405 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. |
3444 \item \code{im.memberName} evaluates to \code{'m'}. | 3406 \item \code{im.memberName} evaluates to \code{'m'}. |
3445 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . | 3407 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . |
3446 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 3408 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3447 \end{itemize} | 3409 \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 : | 3410 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} | 3411 \begin{itemize} |
3450 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3412 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3451 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 3413 \item \code{im.memberName} evaluates to \code{noSuchMethod}. |
3452 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 3414 \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. | 3415 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3454 \end{itemize} | 3416 \end{itemize} |
3455 | 3417 |
3456 and the result of this latter invocation is the result of evaluating $i$. | 3418 and the result of this latter invocation is the result of evaluating $i$. |
3457 | 3419 |
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{}. | 3420 Let $T$ be the static type of $e$. It is a static type warning if $T$ does not have a getter named $m$ unless either: |
3421 \begin{itemize} | |
3422 \item | |
3423 $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 | |
3424 \item $T$ is \code{Type}, $e$ is a constant type literal and the class correspo nding to $e$ has a static getter named $m$. | |
3425 \end{itemize} | |
3459 | 3426 |
3460 Evaluation of a getter invocation $i$ of the form $C.m$ proceeds as follows: | 3427 The static type of $i$ is the declared return type of $T.m$, if $T.m$ exists; ot herwise the static type of $i$ is \DYNAMIC{}. |
3461 | |
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 } | |
3473 | |
3474 The static type of $i$ is the declared return type of $m$. | |
3475 | 3428 |
3476 Evaluation of super getter invocation $i$ of the form $\SUPER{}.m$ proceeds as f ollows: | 3429 Evaluation of super getter invocation $i$ of the form $\SUPER{}.m$ proceeds as f ollows: |
3477 | 3430 |
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. | 3431 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. |
3479 | 3432 |
3480 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 3433 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} | 3434 \begin{itemize} |
3482 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. | 3435 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. |
3483 \item \code{im.memberName} evaluates to \code{'m'}. | 3436 \item \code{im.memberName} evaluates to \code{'m'}. |
3484 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . | 3437 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . |
3485 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. | 3438 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3486 \end{itemize} | 3439 \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 : | 3440 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} | 3441 \begin{itemize} |
3489 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3442 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3490 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 3443 \item \code{im.memberName} evaluates to \code{noSuchMethod}. |
3491 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 3444 \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. | 3445 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3493 \end{itemize} | 3446 \end{itemize} |
3494 | 3447 |
3495 and the result of this latter invocation is the result of evaluating $i$. | 3448 and the result of this latter invocation is the result of evaluating $i$. |
3496 | 3449 |
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{}. | 3450 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{}. |
3498 | 3451 |
3499 Evaluation of a getter invocation of the form $p.C.v$, where $p$ is a deferred p refix, proceeds as follows: | 3452 It is a compile-time error to invoke any of the getters of class \cd{object} on a prefix object (\ref{imports}) or a constant type literal that is not immediate ly enclosed in parentheses. |
3500 | 3453 |
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 | |
3503 | |
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: | |
3505 | |
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. | |
3507 | 3454 |
3508 | 3455 |
3509 | 3456 |
3510 \subsection{ Assignment} | 3457 \subsection{ Assignment} |
3511 \label{assignment} | 3458 \label{assignment} |
3512 | 3459 |
3513 An assignment changes the value associated with a mutable variable or property. | 3460 An assignment changes the value associated with a mutable variable or property. |
3514 | 3461 |
3515 \begin{grammar} | 3462 \begin{grammar} |
3516 {\bf assignmentOperator:}`=' ; | 3463 {\bf assignmentOperator:}`=' ; |
(...skipping 22 matching lines...) Expand all Loading... | |
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$}. | 3486 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 | 3487 |
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. | 3488 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 | 3489 |
3543 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. | 3490 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. |
3544 | 3491 |
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$. | 3492 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 | 3493 |
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$. | 3494 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 | 3495 |
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: | 3496 Evaluation of an assignment of the form $e_1.v$ \code{=} $e_2$ proceeds as follo ws: |
3568 | 3497 |
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$. | 3498 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 | 3499 |
3571 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : | 3500 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} | 3501 \begin{itemize} |
3573 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. | 3502 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. |
3574 \item \code{im.memberName} evaluates to \code{'v='}. | 3503 \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$]}. | 3504 \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{} \{\}}. | 3505 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3577 \end{itemize} | 3506 \end{itemize} |
3578 | 3507 |
3579 Then the method \code{noSuchMethod()} is looked up in $o_1$ and invoked with ar gument $im$. | 3508 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 : | 3509 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} | 3510 \begin{itemize} |
3582 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. | 3511 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. |
3583 \item \code{im.memberName} evaluates to \code{noSuchMethod}. | 3512 \item \code{im.memberName} evaluates to \code{noSuchMethod}. |
3584 \item \code{im.positionalArguments} evaluates to an immutable list whose sole el ement is $im$. | 3513 \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. | 3514 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. |
3586 \end{itemize} | 3515 \end{itemize} |
3587 | 3516 |
3588 The value of the assignment expression is $o_2$ irrespective of whether setter l ookup has failed or succeeded. | 3517 The value of the assignment expression is $o_2$ irrespective of whether setter l ookup has failed or succeeded. |
3589 | 3518 |
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$. | 3519 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 | 3520 |
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$. | 3521 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: |
3522 \begin{itemize} | |
3523 \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 | |
3524 \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=$. | |
3525 \end{itemize} | |
3526 | |
3527 | |
3528 | |
3529 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 | 3530 |
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$. | 3531 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 | 3532 |
3604 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map. | 3533 % Should we add: It is a dynamic error if $e_1$ evaluates to an constant list o r map. |
3605 | 3534 |
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. | 3535 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 | 3536 |
3537 It is a compile-time error to invoke any of the setters of class \cd{object} on a prefix object (\ref{imports}) or a constant type literal that is not immediate ly enclosed in parentheses. | |
3538 | |
3608 | 3539 |
3609 | 3540 |
3610 \subsubsection{Compound Assignment} | 3541 \subsubsection{Compound Assignment} |
3611 \label{compoundAssignment} | 3542 \label{compoundAssignment} |
3612 | 3543 |
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 | 3544 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$. | 3545 \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 | 3546 |
3616 | 3547 |
3617 \begin{grammar} | 3548 \begin{grammar} |
3618 {\bf compoundAssignmentOperator:}`*='; | 3549 {\bf compoundAssignmentOperator:}`*='; |
3619 `/='; | 3550 `/='; |
3620 `\~{}/='; | 3551 `\~{}/='; |
3621 `\%='; | 3552 `\%='; |
3622 `+='; | 3553 `+='; |
3623 `-='; | 3554 `-='; |
3624 `{\escapegrammar \lt \lt}='; | 3555 `{\escapegrammar \lt \lt}='; |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. | 4026 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 } | 4027 } |
4097 | 4028 |
4098 Evaluation of an identifier expression $e$ of the form $id$ proceeds as follows: | 4029 Evaluation of an identifier expression $e$ of the form $id$ proceeds as follows: |
4099 | 4030 |
4100 | 4031 |
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. | 4032 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. | 4033 %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 | 4034 |
4104 \begin{itemize} | 4035 \begin{itemize} |
4036 \item if $d$ is a prefix $p$, a compile-time error occurs unless the token immed iately following $d$ is \code{'.'}. | |
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$. | 4037 \item If $d$ is a class or type alias $T$, the value of $e$ is an instance of cl ass \code{Type} 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. | 4038 \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 | 4039 |
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}.)} | 4040 %\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: | 4041 %\item If $d$ is a library variable then: |
4110 % \begin{itemize} | 4042 % \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$. | 4043 % \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$. | 4044 \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 | 4045 % Otherwise |
4114 % \item $e$ evaluates to the current binding of $id$. | 4046 % \item $e$ evaluates to the current binding of $id$. |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5122 | 5054 |
5123 | 5055 |
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. | 5056 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 | 5057 |
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. | 5058 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 | 5059 |
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{}. | 5060 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 | 5061 |
5130 Let $I$ be an import directive that refers to a URI via the string $s_1$. Evalua tion of $I$ proceeds as follows: | 5062 Let $I$ be an import directive that refers to a URI via the string $s_1$. Evalua tion of $I$ proceeds as follows: |
5131 | 5063 |
5132 If $I$ is a deferred import, no evaluation takes place. Instead, the following n ames are added to the scope of $L$: | 5064 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$. |
5065 The deferred prefix object has the following methods: | |
5066 | |
5133 \begin{itemize} | 5067 \begin{itemize} |
5134 \item | 5068 \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. | 5069 \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 | 5070 \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. | 5071 \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. |
5072 \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} | 5073 \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 | 5074 |
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. | 5075 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 | 5076 |
5144 The effect of a repeated call to \code{$p$.loadLibrary} is as follows: | 5077 The effect of a repeated call to \code{$p$.loadLibrary} is as follows: |
5145 \begin{itemize} | 5078 \begin{itemize} |
5146 \item | 5079 \item |
5147 If another call to \code{$p$.loadLibrary} has already succeeded, the repeated ca ll also succeeds. | 5080 If another call to \code{$p$.loadLibrary} has already succeeded, the repeated ca ll also succeeds. |
5148 Otherwise, | 5081 Otherwise, |
5149 \item | 5082 \item |
5150 If another call to to \code{$p$.loadLibrary} has failed: | 5083 If another call to to \code{$p$.loadLibrary} has failed: |
5151 \begin{itemize} | 5084 \begin{itemize} |
5152 \item | 5085 \item |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5184 | 5117 |
5185 \item If $C_i$ is of the form | 5118 \item If $C_i$ is of the form |
5186 | 5119 |
5187 \code{\HIDE{} $id_1, \ldots, id_k$} | 5120 \code{\HIDE{} $id_1, \ldots, id_k$} |
5188 | 5121 |
5189 then let $NS_i = \HIDE{}([id_1, \ldots, id_k], NS_{i-1}$) | 5122 then let $NS_i = \HIDE{}([id_1, \ldots, id_k], NS_{i-1}$) |
5190 | 5123 |
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. | 5124 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} | 5125 \end{itemize} |
5193 | 5126 |
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$. | 5127 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: |
5128 | |
5129 \begin{itemize} | |
5130 \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$. | |
5131 \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$. | |
5132 \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$. | |
5133 \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$. | |
5134 \end{itemize} | |
5135 | |
5136 Otherwise, let $NS = NS_n$. | |
5195 It is a compile-time error if the current library declares a top-level member na med $p$. | 5137 It is a compile-time error if the current library declares a top-level member na med $p$. |
5196 | 5138 |
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 | 5139 % 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. | 5140 % either. After all, p isn't actually available as a stand alone name. |
5199 | 5141 |
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: | 5142 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} | 5143 \begin{itemize} |
5202 \item | 5144 \item |
5203 a top-level declaration with the name $k$ exists in $L$, OR | 5145 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$. | 5146 \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 Loading... | |
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. | 6026 \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 | 6027 \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. | 6028 \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. | 6029 \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. | 6030 \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} | 6031 \end{itemize} |
6090 } | 6032 } |
6091 | 6033 |
6092 | 6034 |
6093 \end{document} | 6035 \end{document} |
OLD | NEW |