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

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

Issue 1177073002: An attempt to add generic methods to the spec. This is just a draft for purposes of evaluation and … Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync with other spec changes Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 \documentclass{article} 1 \documentclass{article}
2 \usepackage{epsfig} 2 \usepackage{epsfig}
3 \usepackage{color} 3 \usepackage{color}
4 \usepackage{dart} 4 \usepackage{dart}
5 \usepackage{bnf} 5 \usepackage{bnf}
6 \usepackage{hyperref} 6 \usepackage{hyperref}
7 \usepackage{lmodern} 7 \usepackage{lmodern}
8 \newcommand{\code}[1]{{\sf #1}} 8 \newcommand{\code}[1]{{\sf #1}}
9 \title{Dart Programming Language Specification \\ 9 \title{Dart Programming Language Specification - Generic Methods Draft\\
10 {\large Version 1.10}} 10 {\large Version 1.11}}
11 11
12 % For information about Location Markers (and in particular the 12 % For information about Location Markers (and in particular the
13 % commands \LMHash and \LMLabel), see the long comment at the 13 % commands \LMHash and \LMLabel), see the long comment at the
14 % end of this file. 14 % end of this file.
15 15
16 \begin{document} 16 \begin{document}
17 \maketitle 17 \maketitle
18 \tableofcontents 18 \tableofcontents
19 19
20 20
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 529
530 530
531 531
532 532
533 \section{Functions} 533 \section{Functions}
534 \LMLabel{functions} 534 \LMLabel{functions}
535 535
536 \LMHash{} 536 \LMHash{}
537 Functions abstract over executable actions. 537 Functions abstract over executable actions.
538 % Need to fix grammar
538 539
539 \begin{grammar} 540 \begin{grammar}
540 {\bf functionSignature:} 541 {\bf functionSignature:}
541 metadata returnType? identifier formalParameterList 542 metadata returnType? identifier formalParameterList
542 . 543 .
543 544
544 {\bf returnType:} 545 {\bf returnType:}
545 \VOID{}; 546 \VOID{};
546 type 547 type
547 . 548 .
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 \LMHash{} 629 \LMHash{}
629 It is a compile-time error to preface a function declaration with the built-in i dentifier \STATIC{}. 630 It is a compile-time error to preface a function declaration with the built-in i dentifier \STATIC{}.
630 631
631 \LMHash{} 632 \LMHash{}
632 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. 633 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.
633 634
634 635
635 \subsection{Formal Parameters} 636 \subsection{Formal Parameters}
636 \LMLabel{formalParameters} 637 \LMLabel{formalParameters}
637 638
639
638 \LMHash{} 640 \LMHash{}
639 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. 641 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.
640 642
641 \LMHash{} 643 \LMHash{}
642 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. 644 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.
643 645
644 \LMHash{} 646 \LMHash{}
645 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$. 647 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$.
646 648
649 \commentary {
650 A function may be generic, in which case it also has formal type parameters \ref {generics}. The scope of these includes the formal parameter scope and the body scope of the function, as described in section \ref{generics}.
651 }
652
647 653
648 %The formal parameter scope of a function maps the name of each formal parameter $p$ to the value $p$ is bound to. 654 %The formal parameter scope of a function maps the name of each formal parameter $p$ to the value $p$ is bound to.
649 655
650 % The formal parameters of a function are processed in the enclosing scope of th e function. 656 % The formal parameters of a function are processed in the enclosing scope of th e function.
651 % \commentary{this means that the parameters themselves may not be referenced wi thin the formal parameter list.} 657 % \commentary{this means that the parameters themselves may not be referenced wi thin the formal parameter list.}
652 658
653 \LMHash{} 659 \LMHash{}
654 It is a compile-time error if a formal parameter is declared as a constant varia ble (\ref{variables}). 660 It is a compile-time error if a formal parameter is declared as a constant varia ble (\ref{variables}).
655 661
656 \begin{grammar} 662 \begin{grammar}
657 {\bf formalParameterList:}`(' `)'; 663
664 {\bf formalParameterList:}
Brian Wilkerson 2015/06/21 23:32:02 It's a little hard to tell in the review tool, but
gbracha 2015/06/23 20:26:24 We can certainly do that. I don't want to worry ab
665 typeParameters? formalValueParameterList
666 .
667
668 {\bf formalValueParameterList:}`(' `)';
658 `(' normalFormalParameters ( `,' optionalFormalParameters)? `)'; 669 `(' normalFormalParameters ( `,' optionalFormalParameters)? `)';
659 `(' optionalFormalParameters `)' 670 `(' optionalFormalParameters `)'
660 . 671 .
661 %\end{grammar} 672 %\end{grammar}
662 %} 673 %}
663 674
664 %\begin{grammar} 675 %\begin{grammar}
665 %formalParameterList: 676 %formalParameterList:
666 % '(' restFormalParameter? ')'; 677 % '(' restFormalParameter? ')';
667 % '(' namedFormalParameters ')'; 678 % '(' namedFormalParameters ')';
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 If we allowed named parameters to begin with an underscore, they would be consid ered private and inaccessible to callers from outside the library where it was d efined. If a method outside the library overrode a method with a private optiona l name, it would not be a subtype of the original method. The static checker wou ld of course flag such situations, but the consequence would be that adding a pr ivate named formal would break clients outside the library in a way they could n ot easily correct. 763 If we allowed named parameters to begin with an underscore, they would be consid ered private and inaccessible to callers from outside the library where it was d efined. If a method outside the library overrode a method with a private optiona l name, it would not be a subtype of the original method. The static checker wou ld of course flag such situations, but the consequence would be that adding a pr ivate named formal would break clients outside the library in a way they could n ot easily correct.
753 } 764 }
754 765
755 \subsection{Type of a Function} 766 \subsection{Type of a Function}
756 \LMLabel{typeOfAFunction} 767 \LMLabel{typeOfAFunction}
757 768
758 \LMHash{} 769 \LMHash{}
759 If a function does not declare a return type explicitly, its return type is \DYN AMIC{} (\ref{typeDynamic}), unless it is a constructor function, in which case i ts return type is the immediately enclosing class. 770 If a function does not declare a return type explicitly, its return type is \DYN AMIC{} (\ref{typeDynamic}), unless it is a constructor function, in which case i ts return type is the immediately enclosing class.
760 771
761 \LMHash{} 772 \LMHash{}
762 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and no optional parameters. Then the type of $F$ is $(T_1 ,\ldots, T_n) \rightarrow T_0$. 773 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and no optional parameters and no type parameters. Then t he type of $F$ is $(T_1 ,\ldots, T_n) \rightarrow T_0$.
763 774
764 \LMHash{} 775 \LMHash{}
765 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and positional optional parameters $T_{n+1}$ $p_{n+1}, \l dots, T_{n+k}$ $ p_{n+k}$. Then the type of $F$ is $(T_1 ,\ldots, T_n, [T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}]) \rightarrow T_0$. 776 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and positional optional parameters $T_{n+1}$ $p_{n+1}, \l dots, T_{n+k}$ $ p_{n+k}$ and no type parameters. Then the type of $F$ is $(T_1 ,\ldots, T_n, [T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}]) \rightarrow T_0$.
766 777
767 \LMHash{} 778 \LMHash{}
768 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and named optional parameters $T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $ p_{n+k}$. Then the type of $F$ is $(T_1 ,\ldots, T_n, \{T_{n+1}$ $p_ {n+1}, \ldots, T_{n+k}$ $p_{n+k}\}) \rightarrow T_0$. 779 Let $F$ be a function with required formal parameters $T_1$ $p_1 \ldots, T_n$ $p _n$, return type $T_0$ and named optional parameters $T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $ p_{n+k}$ and no type parameters. Then the type of $F$ is $(T_1 ,\ldo ts, T_n, \{T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}\}) \rightarrow T_0$.
780
781 \LMHash{}
782 Let $F$ be a generic function with type parameters $S_1 <: B_1 \ldots S_m <: B_m $. If, in the absence of the type parameters, $F$ would have type $\tau$, then $ F$ has type $\forall S_1 <: B_1 \ldots S_m <: B_m. \tau$.
769 783
770 \LMHash{} 784 \LMHash{}
771 The run time type of a function object always implements the class \cd{Function} . 785 The run time type of a function object always implements the class \cd{Function} .
772 786
773 \commentary{ 787 \commentary{
774 One cannot assume, based on the above, that given a function \cd{f}, \cd{f.runt imeType} will actually be \cd{Function}, or that any two distinct function objec ts necessarily have the same runtime type. 788 One cannot assume, based on the above, that given a function \cd{f}, \cd{f.runt imeType} will actually be \cd{Function}, or that any two distinct function objec ts necessarily have the same runtime type.
775 } 789 }
776 790
777 \rationale{ 791 \rationale{
778 It is up to the implementation to choose an appropriate representation for funct ions. 792 It is up to the implementation to choose an appropriate representation for funct ions.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 954
941 \LMHash{} 955 \LMHash{}
942 It is a static warning if an instance method $m_1$ overrides an instance member $m_2$ and the type of $m_1$ is not a subtype of the type of $m_2$. It is a stati c warning if an instance method $m_1$ overrides an instance member $m_2$, the s ignature of $m_2$ explicitly specifies a default value for a formal parameter $p $ and the signature of $m_1$ implies a different default value for $p$. It is a static warning if a class $C$ declares an instance method named $n$ and has a se tter named $n=$. It is a static warning if a class $C$ declares an instance meth od named $n$ and an accessible static member named $n$ is declared in a supercla ss of $C$. 956 It is a static warning if an instance method $m_1$ overrides an instance member $m_2$ and the type of $m_1$ is not a subtype of the type of $m_2$. It is a stati c warning if an instance method $m_1$ overrides an instance member $m_2$, the s ignature of $m_2$ explicitly specifies a default value for a formal parameter $p $ and the signature of $m_1$ implies a different default value for $p$. It is a static warning if a class $C$ declares an instance method named $n$ and has a se tter named $n=$. It is a static warning if a class $C$ declares an instance meth od named $n$ and an accessible static member named $n$ is declared in a supercla ss of $C$.
943 957
944 % Works. If the name is public, no issue. If it's private, if a subclass has a c onflicting inst var, it either is in the same lib and will be flagged, or is in another and is not an issue. 958 % Works. If the name is public, no issue. If it's private, if a subclass has a c onflicting inst var, it either is in the same lib and will be flagged, or is in another and is not an issue.
945 959
946 960
947 \subsubsection{Operators} 961 \subsubsection{Operators}
948 \LMLabel{operators} 962 \LMLabel{operators}
949 963
964 % So can one declare a generic operator? Only if inference were guaranteed. So w e should ban it in the declaration?
965
950 \LMHash{} 966 \LMHash{}
951 {\em Operators} are instance methods with special names. 967 {\em Operators} are instance methods with special names.
952 968
953 \begin{grammar} 969 \begin{grammar}
954 {\bf operatorSignature:} 970 {\bf operatorSignature:}
955 returnType? \OPERATOR{} operator formalParameterList 971 returnType? \OPERATOR{} operator formalValueParameterList
956 . 972 .
957 973
958 {\bf operator:}`\~{}'; 974 {\bf operator:}`\~{}';
959 binaryOperator; 975 binaryOperator;
960 `[' `]' ; 976 `[' `]' ;
961 `[' `]' `=' 977 `[' `]' `='
962 . 978 .
963 979
964 {\bf binaryOperator:}multiplicativeOperator; 980 {\bf binaryOperator:}multiplicativeOperator;
965 additiveOperator; 981 additiveOperator;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 \subsection{Setters} 1062 \subsection{Setters}
1047 \LMLabel{setters} 1063 \LMLabel{setters}
1048 1064
1049 \LMHash{} 1065 \LMHash{}
1050 Setters are functions (\ref{functions}) that are used to set the values of objec t properties. 1066 Setters are functions (\ref{functions}) that are used to set the values of objec t properties.
1051 1067
1052 % what about top level ones? Same for getters 1068 % what about top level ones? Same for getters
1053 1069
1054 \begin{grammar} 1070 \begin{grammar}
1055 {\bf setterSignature:} 1071 {\bf setterSignature:}
1056 returnType? \SET{} identifier formalParameterList 1072 returnType? \SET{} identifier formalValueParameterList
1057 . 1073 .
1058 \end{grammar} 1074 \end{grammar}
1059 1075
1060 \LMHash{} 1076 \LMHash{}
1061 If no return type is specified, the return type of the setter is \DYNAMIC{}. 1077 If no return type is specified, the return type of the setter is \DYNAMIC{}.
1062 1078
1063 \LMHash{} 1079 \LMHash{}
1064 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. 1080 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.
1065 1081
1066 \commentary{Hence, a setter name can never conflict with, override or be overrid den by a getter or method.} 1082 \commentary{Hence, a setter name can never conflict with, override or be overrid den by a getter or method.}
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 Iff no constructor is specified for a class $C$, it implicitly has a default con structor \code{C() : \SUPER{}() \{\}}, unless $C$ is class \code{Object}. 1219 Iff no constructor is specified for a class $C$, it implicitly has a default con structor \code{C() : \SUPER{}() \{\}}, unless $C$ is class \code{Object}.
1204 1220
1205 \subsubsection{Generative Constructors} 1221 \subsubsection{Generative Constructors}
1206 \LMLabel{generativeConstructors} 1222 \LMLabel{generativeConstructors}
1207 1223
1208 \LMHash{} 1224 \LMHash{}
1209 A {\em generative constructor} consists of a constructor name, a constructor par ameter list, and either a redirect clause or an initializer list and an optiona l body. 1225 A {\em generative constructor} consists of a constructor name, a constructor par ameter list, and either a redirect clause or an initializer list and an optiona l body.
1210 1226
1211 \begin{grammar} 1227 \begin{grammar}
1212 {\bf constructorSignature:} 1228 {\bf constructorSignature:}
1213 identifier (`{\escapegrammar .}' identifier)? formalParameterList 1229 identifier (`{\escapegrammar .}' identifier)? formalValueParameterList
1214 . 1230 .
1215 \end{grammar} 1231 \end{grammar}
1216 1232
1217 \LMHash{} 1233 \LMHash{}
1218 A {\em constructor parameter list} is a parenthesized, comma-separated list of f ormal constructor parameters. A {\em formal constructor parameter} is either a f ormal parameter (\ref{formalParameters}) or an initializing formal. An {\em init ializing formal} has the form \code{\THIS{}.id}, where \code{id} is the name of an instance variable of the immediately enclosing class. It is a compile-time e rror if \code{id} is not an instance variable of the immediately enclosing class . It is a compile-time error if an initializing formal is used by a function oth er than a non-redirecting generative constructor. 1234 A {\em constructor parameter list} is a parenthesized, comma-separated list of f ormal constructor parameters. A {\em formal constructor parameter} is either a f ormal parameter (\ref{formalParameters}) or an initializing formal. An {\em init ializing formal} has the form \code{\THIS{}.id}, where \code{id} is the name of an instance variable of the immediately enclosing class. It is a compile-time e rror if \code{id} is not an instance variable of the immediately enclosing class . It is a compile-time error if an initializing formal is used by a function oth er than a non-redirecting generative constructor.
1219 1235
1220 \LMHash{} 1236 \LMHash{}
1221 If an explicit type is attached to the initializing formal, that is its static t ype. Otherwise, the type of an initializing formal named \code{id} is $T_{id}$, where $T_{id}$ is the type of the field named \code{id} in the immediately enclo sing class. It is a static warning if the static type of \code{id} is not assign able to $T_{id}$. 1237 If an explicit type is attached to the initializing formal, that is its static t ype. Otherwise, the type of an initializing formal named \code{id} is $T_{id}$, where $T_{id}$ is the type of the field named \code{id} in the immediately enclo sing class. It is a static warning if the static type of \code{id} is not assign able to $T_{id}$.
1222 1238
1223 \LMHash{} 1239 \LMHash{}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1275
1260 1276
1261 \paragraph{Redirecting Constructors} 1277 \paragraph{Redirecting Constructors}
1262 \LMLabel{redirectingConstructors} 1278 \LMLabel{redirectingConstructors}
1263 1279
1264 \LMHash{} 1280 \LMHash{}
1265 A generative constructor may be {\em redirecting}, in which case its only action is to invoke another generative constructor. A redirecting constructor has no body; instead, it has a redirect clause that specifies which constructor the inv ocation is redirected to, and with what arguments. 1281 A generative constructor may be {\em redirecting}, in which case its only action is to invoke another generative constructor. A redirecting constructor has no body; instead, it has a redirect clause that specifies which constructor the inv ocation is redirected to, and with what arguments.
1266 1282
1267 \begin{grammar} 1283 \begin{grammar}
1268 {\bf redirection:} 1284 {\bf redirection:}
1269 `{\escapegrammar :}' \THIS{} (`{\escapegrammar .}' identifier)? arguments 1285 `{\escapegrammar :}' \THIS{} (`{\escapegrammar .}' identifier)? valueArgume nts
1270 . 1286 .
1271 \end{grammar} 1287 \end{grammar}
1272 1288
1273 % Need to specify exactly how executing a redirecting constructor works 1289 % Need to specify exactly how executing a redirecting constructor works
1274 1290
1275 1291
1276 %\Q{We now have generative constructors with no bodies as well.} 1292 %\Q{We now have generative constructors with no bodies as well.}
1277 1293
1278 \paragraph{Initializer Lists} 1294 \paragraph{Initializer Lists}
1279 \LMLabel{initializerLists} 1295 \LMLabel{initializerLists}
1280 1296
1281 \LMHash{} 1297 \LMHash{}
1282 An initializer list begins with a colon, and consists of a comma-separated list of individual {\em initializers}. There are two kinds of initializers. 1298 An initializer list begins with a colon, and consists of a comma-separated list of individual {\em initializers}. There are two kinds of initializers.
1283 \begin{itemize} 1299 \begin{itemize}
1284 \item A {\em superinitializer} identifies a {\em superconstructor} - that is, a specific constructor of the superclass. Execution of the superinitializer caus es the initializer list of the superconstructor to be executed. 1300 \item A {\em superinitializer} identifies a {\em superconstructor} - that is, a specific constructor of the superclass. Execution of the superinitializer caus es the initializer list of the superconstructor to be executed.
1285 1301
1286 \item An {\em instance variable initializer} assigns a value to an individual in stance variable. 1302 \item An {\em instance variable initializer} assigns a value to an individual in stance variable.
1287 \end{itemize} 1303 \end{itemize}
1288 1304
1289 \begin{grammar} 1305 \begin{grammar}
1290 {\bf initializers:} 1306 {\bf initializers:}
1291 `{\escapegrammar :}' superCallOrFieldInitializer (`,' superCallOrFieldInit ializer)* 1307 `{\escapegrammar :}' superCallOrFieldInitializer (`,' superCallOrFieldInit ializer)*
1292 . 1308 .
1293 1309
1294 1310
1295 {\bf superCallOrFieldInitializer:}\SUPER{} arguments; 1311 {\bf superCallOrFieldInitializer:}\SUPER{} valueArguments;
1296 \SUPER{} `{\escapegrammar .}' identifier arguments; 1312 \SUPER{} `{\escapegrammar .}' identifier valueArguments;
1297 fieldInitializer 1313 fieldInitializer
1298 . 1314 .
1299 1315
1300 {\bf fieldInitializer:} 1316 {\bf fieldInitializer:}
1301 (\THIS{} `{\escapegrammar .}')? identifier `=' conditionalExpression casca deSection* 1317 (\THIS{} `{\escapegrammar .}')? identifier `=' conditionalExpression casca deSection*
1302 . 1318 .
1303 1319
1304 \end{grammar} 1320 \end{grammar}
1305 1321
1306 \LMHash{} 1322 \LMHash{}
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 It is a compile-time error if class $S$ does not declare a generative constructo r named $S$ (respectively $S.id$). 1402 It is a compile-time error if class $S$ does not declare a generative constructo r named $S$ (respectively $S.id$).
1387 1403
1388 \subsubsection{Factories} 1404 \subsubsection{Factories}
1389 \LMLabel{factories} 1405 \LMLabel{factories}
1390 1406
1391 \LMHash{} 1407 \LMHash{}
1392 A {\em factory} is a constructor prefaced by the built-in identifier (\ref{iden tifierReference}) \FACTORY{}. 1408 A {\em factory} is a constructor prefaced by the built-in identifier (\ref{iden tifierReference}) \FACTORY{}.
1393 1409
1394 \begin{grammar} 1410 \begin{grammar}
1395 {\bf factoryConstructorSignature:} 1411 {\bf factoryConstructorSignature:}
1396 \FACTORY{} identifier (`{\escapegrammar .}' identifier)? formalParameter List 1412 \FACTORY{} identifier (`{\escapegrammar .}' identifier)? formalValuePara meterList
1397 . 1413 .
1398 \end{grammar} 1414 \end{grammar}
1399 1415
1400 1416
1401 %The enclosing scope of a factory constructor is the static scope \ref{} of the class in which it is declared. 1417 %The enclosing scope of a factory constructor is the static scope \ref{} of the class in which it is declared.
1402 1418
1403 \LMHash{} 1419 \LMHash{}
1404 The {\em return type} of a factory whose signature is of the form \FACTORY{} $M$ or the form \FACTORY{} $M.id$ is $M$ if $M$ is not a generic type; otherwise th e return type is $M <T_1, \ldots, T_n>$ where $T_1, \ldots, T_n$ are the type p arameters of the enclosing class 1420 The {\em return type} of a factory whose signature is of the form \FACTORY{} $M$ or the form \FACTORY{} $M.id$ is $M$ if $M$ is not a generic type; otherwise th e return type is $M <T_1, \ldots, T_n>$ where $T_1, \ldots, T_n$ are the type p arameters of the enclosing class
1405 1421
1406 \LMHash{} 1422 \LMHash{}
(...skipping 10 matching lines...) Expand all
1417 } 1433 }
1418 1434
1419 \paragraph{Redirecting Factory Constructors} 1435 \paragraph{Redirecting Factory Constructors}
1420 \LMLabel{redirectingFactoryConstructors} 1436 \LMLabel{redirectingFactoryConstructors}
1421 1437
1422 \LMHash{} 1438 \LMHash{}
1423 A {\em redirecting factory constructor} specifies a call to a constructor of ano ther class that is to be used whenever the redirecting constructor is called. 1439 A {\em redirecting factory constructor} specifies a call to a constructor of ano ther class that is to be used whenever the redirecting constructor is called.
1424 1440
1425 \begin{grammar} 1441 \begin{grammar}
1426 {\bf redirectingFactoryConstructorSignature:} 1442 {\bf redirectingFactoryConstructorSignature:}
1427 \CONST{}? \FACTORY{} identifier (`{\escapegrammar .}' identifier)? formalP arameterList `=' type (`{\escapegrammar .}' identifier)? 1443 \CONST{}? \FACTORY{} identifier (`{\escapegrammar .}' identifier)? formalV alueParameterList `=' type (`{\escapegrammar .}' identifier)?
1428 . 1444 .
1429 \end{grammar} 1445 \end{grammar}
1430 1446
1431 \LMHash{} 1447 \LMHash{}
1432 Calling a redirecting factory constructor $k$ causes the constructor $k^\prime$ denoted by $type$ (respectively, $type.identifier$) to be called with the actual arguments passed to $k$, and returns the result of $k^\prime$ as the result of $k$. The resulting constructor call is governed by the same rules as an instanc e creation expression using \NEW{} (\ref{instanceCreation}). 1448 Calling a redirecting factory constructor $k$ causes the constructor $k^\prime$ denoted by $type$ (respectively, $type.identifier$) to be called with the actual arguments passed to $k$, and returns the result of $k^\prime$ as the result of $k$. The resulting constructor call is governed by the same rules as an instanc e creation expression using \NEW{} (\ref{instanceCreation}).
1433 1449
1434 \commentary{ 1450 \commentary{
1435 It follows that if $type$ or $type.id$ are not defined, or do not refer to a cla ss or constructor, a dynamic error occurs, as with any other undefined construct or call. The same holds if $k$ is called with fewer required parameters or more positional parameters than $k^\prime$ expects, or if $k$ is called with a named parameter that is not declared by $k^\prime$. 1451 It follows that if $type$ or $type.id$ are not defined, or do not refer to a cla ss or constructor, a dynamic error occurs, as with any other undefined construct or call. The same holds if $k$ is called with fewer required parameters or more positional parameters than $k^\prime$ expects, or if $k$ is called with a named parameter that is not declared by $k^\prime$.
1436 } 1452 }
1437 1453
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 1523
1508 1524
1509 \subsubsection{Constant Constructors} 1525 \subsubsection{Constant Constructors}
1510 \LMLabel{constantConstructors} 1526 \LMLabel{constantConstructors}
1511 1527
1512 \LMHash{} 1528 \LMHash{}
1513 A {\em constant constructor} may be used to create compile-time constant (\ref{ constants}) objects. A constant constructor is prefixed by the reserved word \CO NST{}. 1529 A {\em constant constructor} may be used to create compile-time constant (\ref{ constants}) objects. A constant constructor is prefixed by the reserved word \CO NST{}.
1514 1530
1515 \begin{grammar} 1531 \begin{grammar}
1516 {\bf constantConstructorSignature:} 1532 {\bf constantConstructorSignature:}
1517 \CONST{} qualified formalParameterList 1533 \CONST{} qualified formalValueParameterList
1518 . 1534 .
1519 \end{grammar} 1535 \end{grammar}
1520 1536
1521 1537
1522 %\commentary{Spell out subtleties: a constant constructor call within the initia lizer of a constant constructor is treated as a ordinary constructor call (a ne w), because the arguments cannot be assumed constant anymore. In practice, this means two versions are compiled and analyzed. One for new and one for const.} 1538 %\commentary{Spell out subtleties: a constant constructor call within the initia lizer of a constant constructor is treated as a ordinary constructor call (a ne w), because the arguments cannot be assumed constant anymore. In practice, this means two versions are compiled and analyzed. One for new and one for const.}
1523 1539
1524 % \Q{How to specify?} 1540 % \Q{How to specify?}
1525 1541
1526 \commentary{All the work of a constant constructor must be handled via its initi alizers.} 1542 \commentary{All the work of a constant constructor must be handled via its initi alizers.}
1527 1543
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 % tighten definition? do we need chain as for classes? Definition for interface override? 1991 % tighten definition? do we need chain as for classes? Definition for interface override?
1976 1992
1977 \LMHash{} 1993 \LMHash{}
1978 However, if the above rules would cause multiple members $m_1, \ldots, m_k$ wit h the same name $n$ to be inherited (because identically named members existed i n several superinterfaces) then at most one member is inherited. 1994 However, if the above rules would cause multiple members $m_1, \ldots, m_k$ wit h the same name $n$ to be inherited (because identically named members existed i n several superinterfaces) then at most one member is inherited.
1979 1995
1980 \LMHash{} 1996 \LMHash{}
1981 If some but not all of the $m_i, 1 \le i \le k$ are getters none of the $m_i$ ar e inherited, and a static warning is issued. 1997 If some but not all of the $m_i, 1 \le i \le k$ are getters none of the $m_i$ ar e inherited, and a static warning is issued.
1982 1998
1983 \LMHash{} 1999 \LMHash{}
1984 Otherwise, if the static types $T_1, \ldots, T_k$ of the members $m_1, \ldots, m_k$ are not identical, then there must be a member $m_x$ such that $T_x <: T_ i, 1 \le x \le k$ for all $i \in 1..k$, or a static type warning occurs. The m ember that is inherited is $m_x$, if it exists; otherwise: 2000 Otherwise, if the static types $T_1, \ldots, T_k$ of the members $m_1, \ldots, m_k$ are not identical, then there must be a member $m_x$ such that $T_x <: T_ i, 1 \le x \le k$ for all $i \in 1..k$, or a static type warning occurs. The m ember that is inherited is $m_x$, if it exists; otherwise:
2001
2002 \begin{itemize} %generics
2003 \item If not all of the $m_i, i \in 1..k$ are have the same number $Y$ of type parameters, no member is inherited. \rationale{If we do allow ordinary function types to be subtypes of generic function types, we can replace the above rule a nd state that if they don't all have the same number of generic parameters, they have none.}
2004
2005 \item Otherwise,
1985 let $numberOfPositionals(f)$ denote the number of positional parameters of a fu nction $f$, and let $numberOfRequiredParams(f)$ denote the number of required pa rameters of a function $f$. Furthermore, let $s$ denote the set of all named par ameters of the $m_1, \ldots, m_k$. Then let 2006 let $numberOfPositionals(f)$ denote the number of positional parameters of a fu nction $f$, and let $numberOfRequiredParams(f)$ denote the number of required pa rameters of a function $f$. Furthermore, let $s$ denote the set of all named par ameters of the $m_1, \ldots, m_k$. Then let
1986 2007
1987 $h = max(numberOfPositionals(m_i)), $ 2008 $h = max(numberOfPositionals(m_i)), $
1988 2009
1989 $r = min(numberOfRequiredParams(m_i)), i \in 1..k$. 2010 $r = min(numberOfRequiredParams(m_i)), i \in 1..k$.
1990 2011
1991 \LMHash{} 2012 \LMHash{} %generics
1992 Then $I$ has a method named $n$, with $r$ required parameters of type \DYNAMIC{} , $h$ positional parameters of type \DYNAMIC{}, named parameters $s$ of type \ DYNAMIC{} and return type \DYNAMIC{}. 2013 Then $I$ has a method named $n$, with $Y$ type parameters with a bound of \DYNAM IC, $r$ required parameters of type \DYNAMIC, $h$ positional parameters of typ e \DYNAMIC, named parameters $s$ of type \DYNAMIC{} and return type \DYNAMIC{ }.
1993 2014
1994 2015 % We could be smarter about the bounds, but given that we give up on the all the other types, it seems pointless.
1995 2016
1996 \commentary{The only situation where the runtime would be concerned with this wo uld be during reflection, if a mirror attempted to obtain the signature of an in terface member. 2017 \commentary{The only situation where the runtime would be concerned with this wo uld be during reflection, if a mirror attempted to obtain the signature of an in terface member.
1997 } 2018 }
2019 \end{itemize}
1998 2020
1999 \rationale{ 2021 \rationale{
2000 The current solution is a tad complex, but is robust in the face of type annotat ion changes. Alternatives: (a) No member is inherited in case of conflict. (b) The first m is selected (based on order of superinterface list) (c) Inherited me mber chosen at random. 2022 The current solution is a tad complex, but is robust in the face of type annotat ion changes. Alternatives: (a) No member is inherited in case of conflict. (b) The first m is selected (based on order of superinterface list) (c) Inherited me mber chosen at random.
2001 2023
2002 (a) means that the presence of an inherited member of an interface varies depend ing on type signatures. (b) is sensitive to irrelevant details of the declarati on and (c) is liable to give unpredictable results between implementations or ev en between different compilation sessions. 2024 (a) means that the presence of an inherited member of an interface varies depend ing on type signatures. (b) is sensitive to irrelevant details of the declarati on and (c) is liable to give unpredictable results between implementations or ev en between different compilation sessions.
2003 } 2025 }
2004 2026
2005 % Need warnings if overrider conflicts with overriddee either because signatures are incompatible or because done is a method and one is a getter or setter. 2027 % Need warnings if overrider conflicts with overriddee either because signatures are incompatible or because one is a method and one is a getter or setter.
2006 2028
2007 \section{Mixins} 2029 \section{Mixins}
2008 \LMLabel{mixins} 2030 \LMLabel{mixins}
2009 2031
2010 2032
2011 \LMHash{} 2033 \LMHash{}
2012 A mixin describes the difference between a class and its superclass. A mixin is always derived from an existing class declaration. 2034 A mixin describes the difference between a class and its superclass. A mixin is always derived from an existing class declaration.
2013 2035
2014 \LMHash{} 2036 \LMHash{}
2015 It is a compile-time error if a declared or derived mixin refers to \SUPER{}. It is a compile-time error if a declared or derived mixin explicitly declares a co nstructor. It is a compile-time error if a mixin is derived from a class whose s uperclass is not \code{Object}. 2037 It is a compile-time error if a declared or derived mixin refers to \SUPER{}. It is a compile-time error if a declared or derived mixin explicitly declares a co nstructor. It is a compile-time error if a mixin is derived from a class whose s uperclass is not \code{Object}.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 \} 2169 \}
2148 \end{dartCode} 2170 \end{dartCode}
2149 2171
2150 \commentary { 2172 \commentary {
2151 It is also a compile-time error to subclass, mix-in or implement an enum or to e xplicitly instantiate an enum. These restrictions are given in normative form i n sections \ref{superclasses}, \ref{superinterfaces}, \ref{mixinApplication} and \ref{instanceCreation} as appropriate. 2173 It is also a compile-time error to subclass, mix-in or implement an enum or to e xplicitly instantiate an enum. These restrictions are given in normative form i n sections \ref{superclasses}, \ref{superinterfaces}, \ref{mixinApplication} and \ref{instanceCreation} as appropriate.
2152 } 2174 }
2153 2175
2154 \section{Generics} 2176 \section{Generics}
2155 \LMLabel{generics} 2177 \LMLabel{generics}
2156 2178
2157 \LMHash{} 2179 \LMHash{} %generics
2158 A class declaration (\ref{classes}) or type alias (\ref{typedef}) 2180 A class declaration (\ref{classes}), type alias (\ref{typedef}) or function (\re f{functions})
2159 $G$ may be {\em generic}, that is, $G$ may have formal type parameters declared. A generic declaration induces a family of declarations, one for each set of act ual type parameters provided in the program. 2181 $G$ may be {\em generic}, that is, $G$ may have formal type parameters declared. A generic declaration induces a family of declarations, one for each set of act ual type parameters provided in the program.
2160 2182
2161 \begin{grammar} 2183 \begin{grammar}
2162 {\bf typeParameter:} 2184 {\bf typeParameter:}
2163 metadata identifier (\EXTENDS{} type)? 2185 metadata identifier (\EXTENDS{} type)?
2164 . 2186 .
2165 {\bf typeParameters:} 2187 {\bf typeParameters:}
2166 `<' typeParameter (`,' typeParameter)* `>' 2188 `<' typeParameter (`,' typeParameter)* `>'
2167 . 2189 .
2168 \end{grammar} 2190 \end{grammar}
2169 2191
2170 \LMHash{} 2192 \LMHash{}
2171 A type parameter $T$ may be suffixed with an \EXTENDS{} clause that specifies th e {\em upper bound} for $T$. If no \EXTENDS{} clause is present, the upper boun d is \code{Object}. It is a static type warning if a type parameter is a supert ype of its upper bound. The bounds of type variables are a form of type annotati on and have no effect on execution in production mode. 2193 A type parameter $T$ may be suffixed with an \EXTENDS{} clause that specifies th e {\em upper bound} for $T$. If no \EXTENDS{} clause is present, the upper boun d is \code{Object}. It is a static type warning if a type parameter is a supert ype of its upper bound. The bounds of type variables are a form of type annotati on and have no effect on execution in production mode.
2172 2194
2173 \LMHash{} 2195 \LMHash{}
2174 Type parameters are declared in the type-parameter scope of a class. 2196 Type parameters are declared in the type-parameter scope of a class or function.
2175 The type parameters of a generic $G$ are in scope in the bounds of all of the ty pe parameters of $G$. The type parameters of a generic class declaration $G$ are also in scope in the \EXTENDS{} and \IMPLEMENTS{} clauses of $G$ (if these exis t) and in the body of $G$. However, a type parameter is considered to be a mal formed type when referenced by a static member. 2197 The type parameters of a generic $G$ are in scope in the bounds of all of the ty pe parameters of $G$. The type parameters of a generic class declaration $G$ are also in scope in the \EXTENDS{} and \IMPLEMENTS{} clauses of $G$ (if these exis t) and in the body of $G$. However, a class' type parameter is considered to b e a malformed type when referenced by a static member.
2176 2198
2177 \rationale{ 2199 \rationale{
2178 The restriction is necessary since a type variable has no meaning in the context of a static member, because statics are shared among all instantiations of a ge neric. However, a type variable may be referenced from an instance initializer, even though \THIS{} is not available. 2200 The restriction is necessary since a type variable has no meaning in the context of a static member, because statics are shared among all instantiations of a ge neric. However, a type variable may be referenced from an instance initializer, even though \THIS{} is not available.
2179 } 2201 }
2180 2202
2181 \commentary{ 2203 \commentary{
2182 Because type parameters are in scope in their bounds, we support F-bounded quant ification (if you don't know what that is, don't ask). This enables typechecking code such as: 2204 Because type parameters are in scope in their bounds, we support F-bounded quant ification (if you don't know what that is, don't ask). This enables typechecking code such as:
2183 } 2205 }
2184 2206
2185 \begin{dartCode} 2207 \begin{dartCode}
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 2299
2278 2300
2279 \section{Metadata} 2301 \section{Metadata}
2280 \LMLabel{metadata} 2302 \LMLabel{metadata}
2281 2303
2282 \LMHash{} 2304 \LMHash{}
2283 Dart supports metadata which is used to attach user defined annotations to progr am structures. 2305 Dart supports metadata which is used to attach user defined annotations to progr am structures.
2284 2306
2285 \begin{grammar} 2307 \begin{grammar}
2286 {\bf metadata:} 2308 {\bf metadata:}
2287 (`@' qualified ({\escapegrammar `.'} identifier)? (arguments)?)* 2309 (`@' qualified ({\escapegrammar `.'} identifier)? (valueArguments)?)*
2288 . 2310 .
2289 \end{grammar} 2311 \end{grammar}
2290 2312
2291 \LMHash{} 2313 \LMHash{}
2292 Metadata consists of a series of annotations, each of which begin with the chara cter @, followed by a constant expression that starts with an identifier. It is a compile time error if the expression is not one of the following: 2314 Metadata consists of a series of annotations, each of which begin with the chara cter @, followed by a constant expression that starts with an identifier. It is a compile time error if the expression is not one of the following:
2293 \begin{itemize} 2315 \begin{itemize}
2294 \item A reference to a compile-time constant variable. 2316 \item A reference to a compile-time constant variable.
2295 \item A call to a constant constructor. 2317 \item A call to a constant constructor.
2296 \end{itemize} 2318 \end{itemize}
2297 2319
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 is $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightar row Stream{}$. 3208 is $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightar row Stream{}$.
3187 3209
3188 \LMHash{} 3210 \LMHash{}
3189 The static type of a function literal of the form 3211 The static type of a function literal of the form
3190 3212
3191 $(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\})$ $\SYNC*{}$ $\{s\}$ 3213 $(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\})$ $\SYNC*{}$ $\{s\}$
3192 3214
3193 is $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightar row Iterable{}$. 3215 is $(T_1 \ldots, T_n, \{T_{n+1}$ $x_{n+1}, \ldots, T_{n+k}$ $x_{n+k}\}) \rightar row Iterable{}$.
3194 3216
3195 \LMHash{} 3217 \LMHash{}
3218 Let $F$ be a generic function literal with type parameters $S_1 <: B_1 \ldots S_ m <: B_m$. If, in the absence of the type parameters, $F$ would have type $\tau$ , then $F$ has type $\forall S_1 <: B_1 \ldots S_m <: B_m. \tau$.
3219
3220 \LMHash{}
3196 In all of the above cases, whenever $T_i, 1 \le i \le n+k$, is not specified, it is considered to have been specified as \DYNAMIC{}. 3221 In all of the above cases, whenever $T_i, 1 \le i \le n+k$, is not specified, it is considered to have been specified as \DYNAMIC{}.
3197 3222
3223 \LMHash{} %generic
3224 The static type of a function literal of the form
3225 $<P_1$ \EXTENDS{} $B_1, \ldots, P_l$ \EXTENDS{} $B_l> f$ is $\forall P_1 <: B_1, \ldots, P_l <: B_l. fsig$, where $fsig$ is the static type of $f$.
3226
3198 3227
3199 \subsection{ This} 3228 \subsection{ This}
3200 \LMLabel{this} 3229 \LMLabel{this}
3201 3230
3202 \LMHash{} 3231 \LMHash{}
3203 The reserved word \THIS{} denotes the target of the current instance member invo cation. 3232 The reserved word \THIS{} denotes the target of the current instance member invo cation.
3204 3233
3205 \begin{grammar} 3234 \begin{grammar}
3206 {\bf thisExpression:} 3235 {\bf thisExpression:}
3207 \THIS{} 3236 \THIS{}
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3256 3285
3257 3286
3258 \subsubsection{ New} 3287 \subsubsection{ New}
3259 \LMLabel{new} 3288 \LMLabel{new}
3260 3289
3261 \LMHash{} 3290 \LMHash{}
3262 The {\em new expression} invokes a constructor (\ref{constructors}). 3291 The {\em new expression} invokes a constructor (\ref{constructors}).
3263 3292
3264 \begin{grammar} 3293 \begin{grammar}
3265 {\bf newExpression:} 3294 {\bf newExpression:}
3266 \NEW{} type (`{\escapegrammar .}' identifier)? arguments 3295 \NEW{} type (`{\escapegrammar .}' identifier)? valueArguments
3267 . 3296 .
3268 \end{grammar} 3297 \end{grammar}
3269 3298
3270 \LMHash{} 3299 \LMHash{}
3271 Let $e$ be a new expression of the form 3300 Let $e$ be a new expression of the form
3272 3301
3273 \NEW{} $T.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ or the form 3302 \NEW{} $T.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ or the form
3274 3303
3275 \NEW{} $T(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3304 \NEW{} $T(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3276 3305
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 3403
3375 3404
3376 \subsubsection{ Const} 3405 \subsubsection{ Const}
3377 \LMLabel{const} 3406 \LMLabel{const}
3378 3407
3379 \LMHash{} 3408 \LMHash{}
3380 A {\em constant object expression} invokes a constant constructor (\ref{constant Constructors}). 3409 A {\em constant object expression} invokes a constant constructor (\ref{constant Constructors}).
3381 3410
3382 \begin{grammar} 3411 \begin{grammar}
3383 {\bf constObjectExpression:} 3412 {\bf constObjectExpression:}
3384 \CONST{} type ('{\escapegrammar .}' identifier)? arguments 3413 \CONST{} type ('{\escapegrammar .}' identifier)? valueArguments
3385 . 3414 .
3386 \end{grammar} 3415 \end{grammar}
3387 3416
3388 \LMHash{} 3417 \LMHash{}
3389 Let $e$ be a constant object expression of the form 3418 Let $e$ be a constant object expression of the form
3390 3419
3391 \CONST{} $T.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ 3420 \CONST{} $T.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$
3392 3421
3393 or the form \CONST{} $T(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. It is a compile-time error if $T$ does not denote a class accessible in the current scope. It is a compile-time error if $T$ is a deferred type (\re f{staticTypes}). 3422 or the form \CONST{} $T(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. It is a compile-time error if $T$ does not denote a class accessible in the current scope. It is a compile-time error if $T$ is a deferred type (\re f{staticTypes}).
3394 3423
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3500 3529
3501 \commentary{ 3530 \commentary{
3502 As discussed in section \ref{errorsAndWarnings}, the handling of a suspended iso late is the responsibility of the embedder. 3531 As discussed in section \ref{errorsAndWarnings}, the handling of a suspended iso late is the responsibility of the embedder.
3503 } 3532 }
3504 3533
3505 3534
3506 3535
3507 \subsection{ Function Invocation} 3536 \subsection{ Function Invocation}
3508 \LMLabel{functionInvocation} 3537 \LMLabel{functionInvocation}
3509 3538
3510 \LMHash{} 3539 \LMHash{} %generics
3511 Function invocation occurs in the following cases: when a function expression ( \ref{functionExpressions}) is invoked (\ref{functionExpressionInvocation}), when a method (\ref{methodInvocation}), getter (\ref{topLevelGetterInvocation}, \ref {propertyExtraction}) or setter (\ref{assignment}) is invoked or when a construc tor is invoked (either via instance creation (\ref{instanceCreation}), construct or redirection (\ref{redirectingConstructors}) or super initialization). The var ious kinds of function invocation differ as to how the function to be invoked, $ f$, is determined, as well as whether \THIS{} (\ref{this}) is bound. Once $f$ h as been determined, the formal parameters of $f$ are bound to corresponding actu al arguments. When the body of $f$ is executed it will be executed with the afor ementioned bindings. 3540 Function invocation occurs in the following cases: when a function expression ( \ref{functionExpressions}) is invoked (\ref{functionExpressionInvocation}), when a method (\ref{methodInvocation}), getter (\ref{topLevelGetterInvocation}, \ref {propertyExtraction}) or setter (\ref{assignment}) is invoked or when a construc tor is invoked (either via instance creation (\ref{instanceCreation}), construct or redirection (\ref{redirectingConstructors}) or super initialization). The var ious kinds of function invocation differ as to how the function to be invoked, $ f$, is determined, as well as whether \THIS{} (\ref{this}) is bound. Once $f$ h as been determined, the formal type and value parameters of $f$ are bound to cor responding actual arguments. When the body of $f$ is executed it will be execute d with the aforementioned bindings.
3512 3541
3513 \LMHash{} 3542 \LMHash{}
3514 If $f$ is marked \ASYNC{} (\ref{functions}), then a fresh instance (\ref{generat iveConstructors}) $o$ implementing the built-in class \code{Future} is associate d with the invocation and immediately returned to the caller. The body of $f$ is scheduled for execution at some future time. The future $o$ will complete when $f$ terminates. The value used to complete $o$ is the current return value (\ref {return}), if it is defined, and the current exception (\ref{throw}) otherwise. 3543 If $f$ is marked \ASYNC{} (\ref{functions}), then a fresh instance (\ref{generat iveConstructors}) $o$ implementing the built-in class \code{Future} is associate d with the invocation and immediately returned to the caller. The body of $f$ is scheduled for execution at some future time. The future $o$ will complete when $f$ terminates. The value used to complete $o$ is the current return value (\ref {return}), if it is defined, and the current exception (\ref{throw}) otherwise.
3515 3544
3516 \LMHash{} 3545 \LMHash{}
3517 If $f$ is marked \ASYNC* (\ref{functions}), then a fresh instance $s$ implementi ng the built-in class \code{Stream} is associated with the invocation and immedi ately returned. When $s$ is listened to, execution of the body of $f$ will begin . When $f$ terminates: 3546 If $f$ is marked \ASYNC* (\ref{functions}), then a fresh instance $s$ implementi ng the built-in class \code{Stream} is associated with the invocation and immedi ately returned. When $s$ is listened to, execution of the body of $f$ will begin . When $f$ terminates:
3518 \begin{itemize} 3547 \begin{itemize}
3519 \item If the current return value is defined then, if $s$ has been canceled then its cancellation future is completed with \NULL{} (\ref{null}). 3548 \item If the current return value is defined then, if $s$ has been canceled then its cancellation future is completed with \NULL{} (\ref{null}).
3520 \item If the current exception $x$ is defined: 3549 \item If the current exception $x$ is defined:
3521 \begin{itemize} 3550 \begin{itemize}
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3590 3619
3591 3620
3592 \subsubsection{ Actual Argument List Evaluation} 3621 \subsubsection{ Actual Argument List Evaluation}
3593 \LMLabel{actualArguments} 3622 \LMLabel{actualArguments}
3594 3623
3595 \LMHash{} 3624 \LMHash{}
3596 Function invocation involves evaluation of the list of actual arguments to the f unction and binding of the results to the function's formal parameters. 3625 Function invocation involves evaluation of the list of actual arguments to the f unction and binding of the results to the function's formal parameters.
3597 3626
3598 \begin{grammar} 3627 \begin{grammar}
3599 {\bf arguments:} 3628 {\bf arguments:}
3629 typeArguments? valueArguments
3630 .
3631
3632 {\bf valueArguments:}
Brian Wilkerson 2015/06/21 23:32:02 I think the same is true here, that it would resul
3600 `(' argumentList? `)' 3633 `(' argumentList? `)'
3601 . 3634 .
3602 3635
3603 {\bf argumentList:}namedArgument (`,' namedArgument)*; 3636 {\bf argumentList:}namedArgument (`,' namedArgument)*;
3604 % expressionList ',' spreadArgument; 3637 % expressionList ',' spreadArgument;
3605 expressionList (`,' namedArgument)* 3638 expressionList (`,' namedArgument)*
3606 % spreadArgument 3639 % spreadArgument
3607 . 3640 .
3608 3641
3609 {\bf namedArgument:} 3642 {\bf namedArgument:}
(...skipping 12 matching lines...) Expand all
3622 The arguments $a_1, \ldots, a_{m+l}$ are evaluated in the order they appear in t he program, yielding objects $o_1, \ldots, o_{m+l}$. 3655 The arguments $a_1, \ldots, a_{m+l}$ are evaluated in the order they appear in t he program, yielding objects $o_1, \ldots, o_{m+l}$.
3623 3656
3624 \commentary{Simply stated, an argument list consisting of $m$ positional argumen ts and $l$ named arguments is evaluated from left to right. 3657 \commentary{Simply stated, an argument list consisting of $m$ positional argumen ts and $l$ named arguments is evaluated from left to right.
3625 } 3658 }
3626 3659
3627 3660
3628 \subsubsection{ Binding Actuals to Formals} 3661 \subsubsection{ Binding Actuals to Formals}
3629 \LMLabel{bindingActualsToFormals} 3662 \LMLabel{bindingActualsToFormals}
3630 3663
3631 \LMHash{} 3664 \LMHash{}
3632 Let $f$ be a function with $h$ required parameters, let $p_1 \ldots p_n$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{h+k}$ be the optional parameters declared by $f$. 3665 Let $f$ be a function with $s$ type parameters, $h$ required parameters, let $p _1 \ldots p_n$ be the positional parameters of $f$ and let $p_{h+1}, \ldots, p_{ h+k}$ be the optional parameters declared by $f$.
3633 3666
3634 \LMHash{} 3667 \LMHash{}
3635 An evaluated actual argument list $o_1 \ldots o_{m+l}$ derived from an actual ar gument list of the form $(a_1, \ldots, a_m, q_1: a_{m+1}, \ldots, q_l: a_{m+l})$ is bound to the formal parameters of $f$ as follows: 3668 An evaluated actual argument list $o_1 \ldots o_{m+l}$ derived from an actual ar gument list of the form $<A_1, \ldots, A_r>(a_1, \ldots, a_m, q_1: a_{m+1}, \ldo ts, q_l: a_{m+l})$ is bound to the formal parameters of $f$ as follows:
3669
3670 \commentary{
3671 If type arguments are absent, they are taken to \DYNAMIC.
Leaf 2015/06/16 23:23:10 s.b "to be \DYNAMIC"
gbracha 2015/06/18 20:05:59 Done.
3672
3673 We have two possible semantics when the number of type arguments is non-zero and differs from the number of type parameters:
3674
3675 1. If type arguments are provided ($r \ne 0$), their number must match the numbe r of formal type parameters.
3676
3677 2. If there are no type parameters ($r = 0$), any type arguments are ignored. Ot herwise the number of type arguments must match the number of formal type param eters ($r = s$).
Leaf 2015/06/16 23:23:10 s.b. ($s = 0$) ?
gbracha 2015/06/18 20:05:58 No, why? This specifically describes the semantics
Leaf 2015/06/23 01:59:59 I think the ($r = 0$) should be ($s = 0) because r
gbracha 2015/06/23 20:26:24 Yes. I thought r = 0 was supposed to replace r = s
3678 }
3679
3680 \LMHash{}
3681 If $r = 0$, the formal type parameters of $f$ are all bound to \DYNAMIC.
3682 If $s = 0$ any type arguments are ignored. \rationale { This last sentence may b e dropped if we choose to go with the simpler but less compatible semantics.}
3683 Otherwise, $r = s$, then each formal type parameter is bound to the correspondi ng type argument.
3684
3636 3685
3637 \commentary{ 3686 \commentary{
3638 We have an argument list consisting of $m$ positional arguments and $l$ named ar guments. We have a function with $h$ required parameters and $k$ 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. You may not prov ide a given named argument more than once. If an optional parameter has no corr esponding argument, it gets its default value. In checked mode, all arguments mu st belong to subtypes of the type of their corresponding formal. 3687 We have an argument list consisting of $m$ positional arguments and $l$ named ar guments. We have a function with $h$ required parameters and $k$ 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. You may not prov ide a given named argument more than once. If an optional parameter has no corr esponding argument, it gets its default value. In checked mode, all arguments mu st belong to subtypes of the type of their corresponding formal.
3639 } 3688 }
3640 3689
3641 \commentary{ 3690 \commentary{
3642 If $l > 0$, then it is necessarily the case that $n = h$, because a method canno t have both optional positional parameters and named parameters. 3691 If $l > 0$, then it is necessarily the case that $n = h$, because a method canno t have both optional positional parameters and named parameters.
3643 } 3692 }
3644 3693
3645
3646 \LMHash{} 3694 \LMHash{}
3647 If $m < h$, or $m > n$, a \cd{NoSuchMethodError} is thrown. Furthermore, each $ q_i, 1 \le i \le l$, must have a corresponding named parameter in the set $\{p_ {n+1}, \ldots, p_{n +k}\}$ or a \cd{NoSuchMethodError} is thrown. Then $p_i$ is bound to $o_i, i \in 1.. m$, and $q_j$ is bound to $o_{m+j}, j \in 1.. l$. All remaining formal parameters of $f$ are bound to their default values. 3695 %If $m < h$, or $m > n$, a \cd{NoSuchMethodError} is thrown. Furthermore, each $q_i, 1 \le i \le l$, must have a corresponding named parameter in the set $\{p _{n+1}, \ldots, p_{n +k}\}$ or a \cd{NoSuchMethodError} is thrown.
3696 Then $p_i$ is bound to $o_i, i \in 1.. m$, and $q_j$ is bound to $o_{m+j}, j \i n 1.. l$. All remaining formal parameters of $f$ are bound to their default va lues.
3648 3697
3649 \commentary{All of these remaining parameters are necessarily optional and thus have default values.} 3698 \commentary{All of these remaining parameters are necessarily optional and thus have default values.}
3650 3699
3651 \LMHash{} 3700 \LMHash{}
3652 In checked mode, it is a dynamic type error if $o_i$ is not \NULL{} and the act ual type (\ref{actualTypeOfADeclaration}) of $p_i$ is not a supertype of the ty pe of $o_i, i \in 1.. m$. In checked mode, it is a dynamic type error if $o_{m+ j}$ is not \NULL{} and the actual type (\ref{actualTypeOfADeclaration}) of $q_j $ is not a supertype of the type of $o_{m+j}, j \in 1.. l$. 3701 In checked mode, it is a dynamic type error if $o_i$ is not \NULL{} and the act ual type (\ref{actualTypeOfADeclaration}) of $p_i$ is not a supertype of the ty pe of $o_i, i \in 1.. m$. In checked mode, it is a dynamic type error if $o_{m+ j}$ is not \NULL{} and the actual type (\ref{actualTypeOfADeclaration}) of $q_j $ is not a supertype of the type of $o_{m+j}, j \in 1.. l$.
3702 In checked mode, it is a dynamic error if $A_i, 1 \le i \le r$ is not a subtype of the actual type bound of the corresponding type parameter.
3653 3703
3654 \LMHash{} 3704 \LMHash{}
3655 It is a compile-time error if $q_i = q_j$ for any $i \ne j$. 3705 It is a compile-time error if $q_i = q_j$ for any $i \ne j$.
3656 3706
3657 \LMHash{} 3707 \LMHash{}
3658 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$. 3708 Let $T_i$ be the static type of $a_i$, let $S_i$ be the actual type of $p_i, i \ in 1 .. h+k$ and let $S_q$ be the actual type of the named parameter $q$ of $f$. It is a static warning if $T_j$ may not be assigned to $S_j, j \in 1..m$. It is a static warning if $m < h$ or if $m > n$. Furthermore, each $q_i, 1 \le i \l e l$, must have 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 assigned to $S_{q_j}, j \in 1 .. l$.
3659 3709
3660 \subsubsection{ Unqualified Invocation} 3710 \subsubsection{ Unqualified Invocation}
3661 \LMLabel{unqualifiedInvocation} 3711 \LMLabel{unqualifiedInvocation}
3662 3712
3663 \LMHash{} 3713 \LMHash{}
3664 An unqualified function invocation $i$ has the form 3714 An unqualified function invocation $i$ has the form
3665 3715
3666 $id(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k})$, 3716 $id<A_1, \ldots, A_r>(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n +k})$,
3667 3717
3668 where $id$ is an identifier. 3718 where $id$ is an identifier.
3669 3719
3670 \LMHash{} 3720 \LMHash{}
3671 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the innermost such declaration. Then: 3721 If there exists a lexically visible declaration named $id$, let $f_{id}$ be the innermost such declaration. Then:
3672 \begin{itemize} 3722 \begin{itemize}
3673 \item 3723 \item
3674 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}). 3724 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}).
3675 \item 3725 \item
3676 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}) $. 3726 Otherwise, if $f_{id}$ is a static method of the enclosing class $C$, $i$ is equ ivalent to $C.id<A_1, \ldots, A_r>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3677 \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}) $. 3727 \item Otherwise, $f_{id}$ is considered equivalent to the ordinary method invoca tion $\THIS{}.id<A_1, \ldots, A_r>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3678 \end{itemize} 3728 \end{itemize}
3679 3729
3680 %Otherwise, if there is an accessible (\ref{privacy}) static method named $id$ d eclared in a superclass $S$ of the immediately enclosing class $C$ then i is equ ivalent to the static method invocation $S.id(a_1, \ldots, a_n, x_{n+1}: a_{n+1} , \ldots, x_{n+k}: a_{n+k})$. 3730 %Otherwise, if there is an accessible (\ref{privacy}) static method named $id$ d eclared in a superclass $S$ of the immediately enclosing class $C$ then i is equ ivalent to the static method invocation $S.id(a_1, \ldots, a_n, x_{n+1}: a_{n+1} , \ldots, x_{n+k}: a_{n+k})$.
3681 3731
3682 %\rationale{ 3732 %\rationale{
3683 %Unqualified access to static methods of superclasses is inconsistent with the i dea that static methods are not inherited. It is not particularly necessary and may be restricted in future versions. 3733 %Unqualified access to static methods of superclasses is inconsistent with the i dea that static methods are not inherited. It is not particularly necessary and may be restricted in future versions.
3684 %} 3734 %}
3685 3735
3686 \LMHash{} 3736 \LMHash{}
3687 Otherwise, if $i$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $i$ causes a \cd{NoSuchMethodError} to be thrown. 3737 Otherwise, if $i$ occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of $i$ causes a \cd{NoSuchMethodError} to be thrown.
3688 3738
3689 \LMHash{} 3739 \LMHash{}
3690 If $i$ does not occur inside a top level or static function, $i$ is equivalent t o $\THIS{}.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3740 If $i$ does not occur inside a top level or static function, $i$ is equivalent t o $\THIS{}.id<A_1, \ldots, A_r>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x _{n+k}: a_{n+k})$.
3691 3741
3692 % Should also say: 3742 % Should also say:
3693 % It is a static warning if $i$ occurs inside a top level or static function (b e it function, method, getter, or setter) or variable initializer and there is no lexically visible declaration named $id$ in scope. 3743 % It is a static warning if $i$ occurs inside a top level or static function (b e it function, method, getter, or setter) or variable initializer and there is no lexically visible declaration named $id$ in scope.
3694 3744
3695 3745
3696 3746
3697 3747
3698 3748
3699 \subsubsection{ Function Expression Invocation} 3749 \subsubsection{ Function Expression Invocation}
3700 \LMLabel{functionExpressionInvocation} 3750 \LMLabel{functionExpressionInvocation}
3701 3751
3702 \LMHash{} 3752 \LMHash{}
3703 A function expression invocation $i$ has the form 3753 A function expression invocation $i$ has the form
3704 3754
3705 $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$, 3755 $e_f<A_1, \ldots, A_m>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a _{n+k})$,
3706 3756
3707 where $e_f$ is an expression. If $e_f$ is an identifier $id$, then $id$ must nec essarily denote a local function, a library function, a library or static getter or a variable as described above, or $i$ is not considered a function expressio n invocation. If $e_f$ is a property extraction expression (\ref{propertyExtract ion}), then $i$ is is not a function expression invocation and is instead recogn ized as an ordinary method invocation (\ref{ordinaryInvocation}). 3757 where $e_f$ is an expression. If $e_f$ is an identifier $id$, then $id$ must nec essarily denote a local function, a library function, a library or static getter or a variable as described above, or $i$ is not considered a function expressio n invocation. If $e_f$ is a property extraction expression (\ref{propertyExtract ion}), then $i$ is is not a function expression invocation and is instead recogn ized as an ordinary method invocation (\ref{ordinaryInvocation}).
3708 3758
3709 \commentary{ 3759 \commentary{
3710 \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on objec t \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed b y a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, t he two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invoc ation} passed to \code{noSuchMethod()} would describe a call to a method \code{$ b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b $} (with no arguments) in the latter. 3760 \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on objec t \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed b y a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, t he two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invoc ation} passed to \code{noSuchMethod()} would describe a call to a method \code{$ b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b $} (with no arguments) in the latter.
3711 } 3761 }
3712 3762
3713 \LMHash{} 3763 \LMHash{}
3714 Otherwise: 3764 Otherwise:
3715 3765
3716 A function expression invocation $e_f(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldot s , x_{n+k}: a_{n+k})$ is equivalent to $e_f.call(a_1, \ldots , a_n, x_{n+1}: a_ {n+1}, \ldots , x_{n+k}: a_{n+k})$. 3766 A function expression invocation $e_f<A_1, \ldots, A_m>(a_1, \ldots , a_n, x_{n +1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is equivalent to $e_f.call<A_1, \ldots , A_m>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3717 3767
3718 \commentary{ 3768 \commentary{
3719 The implication of this definition, and the other definitions involving the meth od \code{call()}, is that user defined types can be used as function values prov ided they define a \CALL{} method. The method \CALL{} is special in this regard. The signature of the \CALL{} method determines the signature used when using th e object via the built-in invocation syntax. 3769 The implication of this definition, and the other definitions involving the meth od \code{call()}, is that user defined types can be used as function values prov ided they define a \CALL{} method. The method \CALL{} is special in this regard. The signature of the \CALL{} method determines the signature used when using th e object via the built-in invocation syntax.
3720 } 3770 }
3721 3771
3722 \LMHash{} 3772 \LMHash{}
3723 It is a static warning if the static type $F$ of $e_f$ may not be assigned to a function type. If $F$ is not a function type, the static type of $i$ is \DYNAMI C{}. Otherwise 3773 It is a static warning if the static type $F$ of $e_f$ may not be assigned to a function type. If $F$ is not a function type, the static type of $i$ is \DYNAMI C{}. Otherwise
3724 the static type of $i$ is the declared return type of $F$. 3774 the static type of $i$ is the actual return type (\ref{actualTypeOfADeclaration} ) of $F$.
3725 %\item Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static war ning if $F$ is not a supertype of $(T_1, \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldot s, T_{n+k}$ $x_{n+k}]) \to \bot$. 3775 %\item Let $T_i$ be the static type of $a_i, i \in 1 .. n+k$. It is a static war ning if $F$ is not a supertype of $(T_1, \ldots, T_n, [T_{n+1}$ $x_{n+1}, \ldot s, T_{n+k}$ $x_{n+k}]) \to \bot$.
3726 %\end{itemize} 3776 %\end{itemize}
3727 3777
3728 \subsection{ Lookup} 3778 \subsection{ Lookup}
3729 \LMLabel{lookup} 3779 \LMLabel{lookup}
3730 3780
3731 \subsubsection{Method Lookup} 3781 \subsubsection{Method Lookup}
3732 \LMLabel{methodLookup} 3782 \LMLabel{methodLookup}
3733 3783
3734 \LMHash{} 3784 \LMHash{}
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3782 \subsubsection{Ordinary Invocation} 3832 \subsubsection{Ordinary Invocation}
3783 \LMLabel{ordinaryInvocation} 3833 \LMLabel{ordinaryInvocation}
3784 3834
3785 \LMHash{} 3835 \LMHash{}
3786 An ordinary method invocation can be {\em conditional} or {\em unconditional}. 3836 An ordinary method invocation can be {\em conditional} or {\em unconditional}.
3787 3837
3788 \LMHash{} 3838 \LMHash{}
3789 Evaluation of a {\em conditional ordinary method invocation} $e$ of the form 3839 Evaluation of a {\em conditional ordinary method invocation} $e$ of the form
3790 3840
3791 \LMHash{} 3841 \LMHash{}
3792 $o?.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ 3842 $o?.m<A_1, \ldots, A_r>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$
3793 3843
3794 \LMHash{} 3844 \LMHash{}
3795 is equivalent to the evaluation of the expression 3845 is equivalent to the evaluation of the expression
3796 3846
3797 \LMHash{} 3847 \LMHash{}
3798 $((x) => x == \NULL ? \NULL : x.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}))(o)$. 3848 $((x) => x == \NULL ? \NULL : x.m<A_1, \ldots, A_r>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k}))(o)$.
3799 3849
3800 \LMHash{} 3850 \LMHash{}
3801 The static type of $e$ is the same as the static type of $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. Exactly the same static warnings that would be caused by $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n +k}: a_{n+k})$ are also generated in the case of $o?.m(a_1, \ldots , a_n, x_{n+1 }: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3851 The static type of $e$ is the same as the static type of $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. Exactly the same static warnings that would be caused by $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n +k}: a_{n+k})$ are also generated in the case of $o?.m(a_1, \ldots , a_n, x_{n+1 }: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$.
3802 3852
3803 \LMHash{} 3853 \LMHash{}
3804 An {\em unconditional ordinary method invocation} $i$ has the form 3854 An {\em unconditional ordinary method invocation} $i$ has the form
3805 3855
3806 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3856 $o.m<A_1, \ldots, A_r>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a _{n+k})$.
3807 3857
3808 \LMHash{} 3858 \LMHash{}
3809 Evaluation of an unconditional ordinary method invocation $i$ of the form 3859 Evaluation of an unconditional ordinary method invocation $i$ of the form
3810 3860
3811 $o.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ 3861 $o.m<A_1, \ldots, A_r>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a _{n+k})$
3812 3862
3813 proceeds as follows: 3863 proceeds as follows:
3814 3864
3815 \LMHash{} 3865 \LMHash{}
3816 First, the expression $o$ is evaluated to a value $v_o$. Next, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k}$. Let $f$ be the result of looking up (\ref{methodLookup}) method $m$ in $v_o$ with respect to the cur rent library $L$. 3866 First, the expression $o$ is evaluated to a value $v_o$. Next, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$ is evaluated yielding actual argument objects $o_1, \ldots , o_{n+k}$. Let $f$ be the result of looking up (\ref{methodLookup}) method $m$ in $v_o$ with respect to the cur rent library $L$.
3817 3867
3818 \LMHash{} 3868 \LMHash{}
3819 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$. 3869 Let $T_1 \ldots T_s$ be the type parameters of $f$,
3870 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$.
3820 3871
3821 \commentary{ 3872 \commentary{
3822 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. 3873 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.
3874
3875 The argument list also contains $r$ type arguments, and the function has $s$ for mal type parameters. If $r$ and $s$ are non-zero, they must match.
3876
3877 If $r = 0$ then we simply pass in \DYNAMIC{} as described below.
3878
3879 If $s = 0$ then we ignore any type arguments.
3880 }
3881
3882 \rationale{
3883
3884 We have a choice between two semantics:
3885
3886 One in which parametrically polymorphic function types are subtypes of non-para metrically polymorphic ones, and one in which they are not. The commentary refle cts the former, as it is more compatible, though harder to implement.
3887
3888 Both options are listed in the normative text below.
3889 To choose one option or the other here, we eliminate one of the normative lines directly below this remark, and modify the commentary as needed.
3823 } 3890 }
3824 3891
3825 \LMHash{} 3892 \LMHash{}
3893 If $r \ne s$ and $r \ne 0$ the method lookup has failed.
3894
3895 \LMHash{}
3896 If $r \ne s$ and either $r \ne 0$ or $s \ne 0$, the method lookup has failed.
3897
3898
3826 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. 3899 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.
3827 3900
3828 \LMHash{} 3901 \LMHash{}
3829 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. 3902 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, with \THIS{} b ound to $v_o$. The value of $i$ is the value returned after $f$ is executed.
3830 3903
3831 \LMHash{} 3904 \LMHash{}
3832 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$. 3905 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$.
3833 If $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, t hen if $g$ is a getter that forwards to a static getter, getter lookup fails. 3906 If $v_o$ is an instance of \code{Type} but $o$ is not a constant type literal, t hen if $g$ is a getter that forwards to a static getter, getter lookup fails.
3834 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 3907 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
3835 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}\}$. 3908 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}\}, [A_1, \ldots, A_r]$.
Leaf 2015/06/16 23:23:10 s.b "with arguments $v_g, " ?
gbracha 2015/06/18 20:05:58 Done.
3836 3909
Leaf 2015/06/16 23:23:10 I think there's a small issue with expressing this
gbracha 2015/06/18 20:05:59 Yes and no. I'm not saying this is the call Functi
Leaf 2015/06/23 01:59:59 Ok.
3837 \LMHash{} 3910 \LMHash{}
3838 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : 3911 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that :
3839 \begin{itemize} 3912 \begin{itemize}
3840 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 3913 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3841 \item \code{im.memberName} evaluates to the symbol \code{m}. 3914 \item \code{im.memberName} evaluates to the symbol \code{m}.
3842 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. 3915 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}.
3843 \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}$\}}. 3916 \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}$\}}.
3917 \item \code{im.typeArguments} evaluates to an immutable list with the same value s as \code{[$A_1, \ldots, A_r$]}. \rationale{We need to pass the actual type ar guments used to \cd{noSuchMethod}, which is why we use the $A_i$ rather than the $V_i$. If no argument were passed, the handler can choose to use \DYNAMIC{} at its discretion.}
Leaf 2015/06/16 23:23:10 What are the $V_i$? I looked in the surrounding te
gbracha 2015/06/18 20:05:59 There used to be V_i, representing the type argume
3844 \end{itemize} 3918 \end{itemize}
3845 3919
3846 \LMHash{} 3920 \LMHash{}
3847 Then the method \code{noSuchMethod()} is looked up in $v_o$ and invoked with arg ument $im$, and the result of this invocation is the result of evaluating $i$. H owever, if the implementation found cannot be invoked with a single positional a rgument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $v_o$ with argument $im'$, where $im'$ is an instance of \code{Invoca tion} such that : 3921 Then the method \code{noSuchMethod()} is looked up in $v_o$ and invoked with arg ument $im$, and the result of this invocation is the result of evaluating $i$. H owever, if the implementation found cannot be invoked with a single positional a rgument, the implementation of \code{noSuchMethod()} in class \code{Object} is invoked on $v_o$ with argument $im'$, where $im'$ is an instance of \code{Invoca tion} such that :
3848 \begin{itemize} 3922 \begin{itemize}
3849 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. 3923 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}.
3850 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. 3924 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}.
3851 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. 3925 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$.
3852 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 3926 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
3927 \item \code{im'.typeArguments} evaluates to the value of \code{\CONST{} []}.
3853 \end{itemize} 3928 \end{itemize}
3854 3929
3855 and the result of the latter invocation is the result of evaluating $i$. 3930 and the result of the latter invocation is the result of evaluating $i$.
3856 3931
3857 \rationale { 3932 \rationale {
3858 It is possible to bring about such a situation by overriding \code{noSuchMethod( )} with the wrong number of arguments:} 3933 It is possible to bring about such a situation by overriding \code{noSuchMethod( )} with the wrong number of arguments:}
3859 3934
3860 \begin{code} 3935 \begin{code}
3861 \CLASS{} Perverse \{ 3936 \CLASS{} Perverse \{
3862 noSuchMethod(x,y) =$>$ x + y; 3937 noSuchMethod(x,y) =$>$ x + y;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 3982
3908 The present specification has not added such a construct, in the interests of si mplicity and rapid language evolution. However, Dart implementations may experim ent with such constructs, as noted in section \ref{ecmaConformance}. 3983 The present specification has not added such a construct, in the interests of si mplicity and rapid language evolution. However, Dart implementations may experim ent with such constructs, as noted in section \ref{ecmaConformance}.
3909 } 3984 }
3910 3985
3911 \subsubsection{Super Invocation} 3986 \subsubsection{Super Invocation}
3912 \LMLabel{superInvocation} 3987 \LMLabel{superInvocation}
3913 3988
3914 \LMHash{} 3989 \LMHash{}
3915 A super method invocation $i$ has the form 3990 A super method invocation $i$ has the form
3916 3991
3917 $\SUPER{}.m(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k}: a_{n+k})$. 3992 $\SUPER{}.m<A_1, \ldots, A_r>(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{ n+k}: a_{n+k})$.
3918 3993
3919 \LMHash{} 3994 \LMHash{}
3920 Evaluation of $i$ proceeds as follows: 3995 Evaluation of $i$ proceeds as follows:
3921 3996
3922 \LMHash{} 3997 \LMHash{}
3923 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{methodLookup}) $m$ in $S$ with respect to the current library $L$. 3998 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{methodLookup}) $m$ in $S$ with respect to the current library $L$.
3924 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$. 3999 Let $T_1 \ldots T_s$ be the type parameters of $f$, 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 optional parameters declared by $f$.
4000
4001
4002 \rationale{Again, we have a choice between the next two lines}
4003
4004 \LMHash{}
4005 If $r \ne s$ and $r \ne 0$ the method lookup has failed.
4006
4007 \LMHash{}
4008 If $r \ne s$ and either $r \ne 0$ or $s \ne 0$, the method lookup has failed.
4009
3925 4010
3926 \LMHash{} 4011 \LMHash{}
3927 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. 4012 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.
3928 4013
3929 \LMHash{} 4014 \LMHash{}
3930 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 the current value of \THIS{}. The value of $i$ is the value returned after $f$ is executed. 4015 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 the current value of \THIS{}. The value of $i$ is the value returned after $f$ is executed.
3931 4016
3932 \LMHash{} 4017 \LMHash{}
3933 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $S$ with respect to $L$. If the getter loo kup succeeded, let $v_g$ be the value of the getter invocation $\SUPER{}.m$. The n the value of $i$ is the result of invoking 4018 If the method lookup has failed, then let $g$ be the result of looking up getter (\ref{getterAndSetterLookup}) $m$ in $S$ with respect to $L$. If the getter loo kup succeeded, let $v_g$ be the value of the getter invocation $\SUPER{}.m$. The n the value of $i$ is the result of invoking
3934 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}\}$. 4019 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}\}, [A_1, \ldots, A_r]$.
3935 4020
3936 \LMHash{} 4021 \LMHash{}
3937 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that : 4022 If getter lookup has also failed, then a new instance $im$ of the predefined c lass \code{Invocation} is created, such that :
3938 \begin{itemize} 4023 \begin{itemize}
3939 \item \code{im.isMethod} evaluates to \code{\TRUE{}}. 4024 \item \code{im.isMethod} evaluates to \code{\TRUE{}}.
3940 \item \code{im.memberName} evaluates to the symbol \code{m}. 4025 \item \code{im.memberName} evaluates to the symbol \code{m}.
3941 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}. 4026 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_1, \ldots, o_n$]}.
3942 \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}$\}}. 4027 \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}$\}}.
4028 \item \code{im.typeArguments} evaluates to an immutable list with the same value s as \code{[$A_1, \ldots, A_r$]}.
3943 \end{itemize} 4029 \end{itemize}
3944 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 : 4030 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 :
3945 \begin{itemize} 4031 \begin{itemize}
3946 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. 4032 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}.
3947 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. 4033 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}.
3948 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. 4034 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$.
3949 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4035 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4036 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
3950 \end{itemize} 4037 \end{itemize}
3951 4038
3952 and the result of this latter invocation is the result of evaluating $i$. 4039 and the result of this latter invocation is the result of evaluating $i$.
3953 4040
3954 4041
3955 \LMHash{} 4042 \LMHash{}
3956 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. 4043 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.
3957 4044
3958 \LMHash{} 4045 \LMHash{}
3959 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$. 4046 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 actual return type of $F$.
3960 % The following is not needed because it is specified in 'Binding Actuals to For mals" 4047 % The following is not needed because it is specified in 'Binding Actuals to For mals"
3961 %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$. 4048 %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$.
3962 4049
3963 4050
3964 4051
3965 4052
3966 \subsubsection{Sending Messages} 4053 \subsubsection{Sending Messages}
3967 \LMLabel{sendingMessages} 4054 \LMLabel{sendingMessages}
3968 4055
3969 \LMHash{} 4056 \LMHash{}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4020 Otherwise, $i$ is a getter invocation. Let $f$ be the result of looking up 4107 Otherwise, $i$ is a getter invocation. Let $f$ be the result of looking up
4021 (\ref{getterAndSetterLookup}) getter (\ref{getters}) $m$ in $o$ with respect to $L$. If $o$ is an instance of \code{Type} but $e$ is not a constant type litera l, then if $f$ is a getter that forwards to a static getter, getter lookup fai ls. Otherwise, the body of $f$ is executed with \THIS{} bound to $o$. The value of $i$ is the result returned by the call to the getter function. 4108 (\ref{getterAndSetterLookup}) getter (\ref{getters}) $m$ in $o$ with respect to $L$. If $o$ is an instance of \code{Type} but $e$ is not a constant type litera l, then if $f$ is a getter that forwards to a static getter, getter lookup fai ls. Otherwise, the body of $f$ is executed with \THIS{} bound to $o$. The value of $i$ is the result returned by the call to the getter function.
4022 4109
4023 \LMHash{} 4110 \LMHash{}
4024 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : 4111 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that :
4025 \begin{itemize} 4112 \begin{itemize}
4026 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. 4113 \item \code{im.isGetter} evaluates to \code{\TRUE{}}.
4027 \item \code{im.memberName} evaluates to the symbol \code{m}. 4114 \item \code{im.memberName} evaluates to the symbol \code{m}.
4028 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . 4115 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} .
4029 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4116 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4117 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
4030 \end{itemize} 4118 \end{itemize}
4031 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 : 4119 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 :
4032 \begin{itemize} 4120 \begin{itemize}
4033 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. 4121 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}.
4034 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. 4122 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}.
4035 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. 4123 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$.
4036 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4124 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4125 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
4037 \end{itemize} 4126 \end{itemize}
4038 4127
4039 and the result of this latter invocation is the result of evaluating $i$. 4128 and the result of this latter invocation is the result of evaluating $i$.
4040 4129
4041 \LMHash{} 4130 \LMHash{}
4042 It is a compile-time error if $m$ is a member of class \cd{Object} and $e$ is ei ther a prefix object (\ref{imports}) or a constant type literal. 4131 It is a compile-time error if $m$ is a member of class \cd{Object} and $e$ is ei ther a prefix object (\ref{imports}) or a constant type literal.
4043 4132
4044 \commentary { 4133 \commentary {
4045 This precludes \code{int.toString} but not \code{(int).toString} because in the latter case, $e$ is a parenthesized expression. 4134 This precludes \code{int.toString} but not \code{(int).toString} because in the latter case, $e$ is a parenthesized expression.
4046 } 4135 }
(...skipping 29 matching lines...) Expand all
4076 \LMHash{} 4165 \LMHash{}
4077 Otherwise, $i$ is a getter invocation. Let $f$ be the result of looking up ge tter $m$ in $S$ with respect to $L$. The body of $f$ is executed with \THIS{} bound to the current value of \THIS{}. The value of $i$ is the result returne d by the call to the getter function. 4166 Otherwise, $i$ is a getter invocation. Let $f$ be the result of looking up ge tter $m$ in $S$ with respect to $L$. The body of $f$ is executed with \THIS{} bound to the current value of \THIS{}. The value of $i$ is the result returne d by the call to the getter function.
4078 4167
4079 \LMHash{} 4168 \LMHash{}
4080 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : 4169 If the getter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that :
4081 \begin{itemize} 4170 \begin{itemize}
4082 \item \code{im.isGetter} evaluates to \code{\TRUE{}}. 4171 \item \code{im.isGetter} evaluates to \code{\TRUE{}}.
4083 \item \code{im.memberName} evaluates to the symbol \code{m}. 4172 \item \code{im.memberName} evaluates to the symbol \code{m}.
4084 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} . 4173 \item \code{im.positionalArguments} evaluates to the value of \code{\CONST{} []} .
4085 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4174 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4175 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
4086 \end{itemize} 4176 \end{itemize}
4087 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 : 4177 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 :
4088 \begin{itemize} 4178 \begin{itemize}
4089 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. 4179 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}.
4090 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. 4180 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}.
4091 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. 4181 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$.
4092 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4182 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4183 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
4093 \end{itemize} 4184 \end{itemize}
4094 and the result of this latter invocation is the result of evaluating $i$. 4185 and the result of this latter invocation is the result of evaluating $i$.
4095 4186
4096 \LMHash{} 4187 \LMHash{}
4097 It is a static type warning if $S$ does not have an accessible instance method o r getter named $m$. 4188 It is a static type warning if $S$ does not have an accessible instance method o r getter named $m$.
4098 4189
4099 The static type of $i$ is: 4190 The static type of $i$ is:
4100 \begin{itemize} 4191 \begin{itemize}
4101 \item The declared return type of $S.m$, if $S$ has an accessible instance gette r named $m$. 4192 \item The declared return type of $S.m$, if $S$ has an accessible instance gette r named $m$.
4102 \item The static type of function $S.m$ if $S$ has an accessible instance method named $m$. 4193 \item The static type of function $S.m$ if $S$ has an accessible instance method named $m$.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
4231 \LMHash{} 4322 \LMHash{}
4232 Let $o$ be an object, and let $u$ be a fresh final variable bound to $o$. 4323 Let $o$ be an object, and let $u$ be a fresh final variable bound to $o$.
4233 The {\em closurization of method $f$ on object $o$} is defined to be equivalent to: 4324 The {\em closurization of method $f$ on object $o$} is defined to be equivalent to:
4234 \begin{itemize} 4325 \begin{itemize}
4235 \item $(a) \{\RETURN{}$ $u$ $op$ $a;$\} if $f$ is named $op$ and $op$ is one of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<<$, $> >$} (this precludes closurization of unary -). 4326 \item $(a) \{\RETURN{}$ $u$ $op$ $a;$\} if $f$ is named $op$ and $op$ is one of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<<$, $> >$} (this precludes closurization of unary -).
4236 \item $() \{\RETURN{}$ \~{} $u;$\} if $f$ is named \~{}. 4327 \item $() \{\RETURN{}$ \~{} $u;$\} if $f$ is named \~{}.
4237 \item $(a) \{\RETURN{}$ $u[a];$\} if $f$ is named $[]$. 4328 \item $(a) \{\RETURN{}$ $u[a];$\} if $f$ is named $[]$.
4238 \item $(a, b) \{\RETURN{}$ $u[a] = b;$\} if $f$ is named $[]=$. 4329 \item $(a, b) \{\RETURN{}$ $u[a] = b;$\} if $f$ is named $[]=$.
4239 \item 4330 \item
4240 \begin{dartCode} 4331 \begin{dartCode}
4241 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ 4332 $<T_1, \ldots, T_s>(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{
4242 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ 4333 \RETURN{} $ u.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$
4243 \} 4334 \}
Leaf 2015/06/16 23:23:10 Is it intentional that the type parameters are dro
gbracha 2015/06/18 20:05:59 No, it's not intentional. It's called a bug. Fixed
Leaf 2015/06/23 01:59:59 Well you know, one man's bug is another man's feat
4244 \end{dartCode} 4335 \end{dartCode}
4245 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and named pa rameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. 4336 if $f$ is named $m$ and has type parameters $T_1, \ldots, T_s$, required param eters $r_1, \ldots, r_n$, and named parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
4246 \item 4337 \item
4247 \begin{dartCode} 4338 \begin{dartCode}
4248 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ 4339 $<T_1, \ldots, T_s>(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{
4249 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; 4340 \RETURN{} $u.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$;
4250 \} 4341 \}
4251 \end{dartCode} 4342 \end{dartCode}
4252 4343
4253 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. 4344 if $f$ is named $m$ and has type parameters $T_1, \ldots, T_s$, required para meters $r_1, \ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
4254 \end{itemize} 4345 \end{itemize}
4255 4346
Leaf 2015/06/16 23:23:10 If I'm reading this correctly, neither the closuri
gbracha 2015/06/18 20:05:58 Yes, that is correct. We should discuss where you
Leaf 2015/06/23 02:00:00 My original DEP proposal used this a fair bit in t
gbracha 2015/06/23 20:26:24 Ok, we can discuss.
4256 \LMHash{} 4347 \LMHash{}
4257 Except that iff \code{identical($o_1, o_2$)} then \cd{$o_1\#m$ == $o_2\#m$}, \cd{$o_1.m$ == $o_2.m$}, \cd{$o_1\#m$ == $o_2.m$} and \cd{$o_1.m$ == $o_2\#m$} . 4348 Except that iff \code{identical($o_1, o_2$)} then \cd{$o_1\#m$ == $o_2\#m$}, \cd{$o_1.m$ == $o_2.m$}, \cd{$o_1\#m$ == $o_2.m$} and \cd{$o_1.m$ == $o_2\#m$} .
4258 %\item The static type of the property extraction is the static type of function $T.m$, where $T$ is the static type of $e$, if $T.m$ is defined. Otherwise the static type of $e.m$ is \DYNAMIC{}. 4349 %\item The static type of the property extraction is the static type of function $T.m$, where $T$ is the static type of $e$, if $T.m$ is defined. Otherwise the static type of $e.m$ is \DYNAMIC{}.
4259 4350
4260 \LMHash{} 4351 \LMHash{}
4261 The {\em closurization of getter $f$ on object $o$} is defined to be equivalent to \cd{()\{\RETURN{} u.m;\}} if $f$ is named $m$, except that iff \code{identic al($o_1, o_2$)} then \cd{$o_1\#m$ == $o_2\#m$}. 4352 The {\em closurization of getter $f$ on object $o$} is defined to be equivalent to \cd{()\{\RETURN{} u.m;\}} if $f$ is named $m$, except that iff \code{identic al($o_1, o_2$)} then \cd{$o_1\#m$ == $o_2\#m$}.
4262 4353
4263 \LMHash{} 4354 \LMHash{}
4264 The {\em closurization of setter $f$ on object $o$} is defined to be equivalent to \cd{(a)\{\RETURN{} u.m = a;\}} if $f$ is named $m=$, except that iff \code{i dentical($o_1, o_2$)} then \cd{$o_1\#m=$ == $o_2\#m=$}. 4355 The {\em closurization of setter $f$ on object $o$} is defined to be equivalent to \cd{(a)\{\RETURN{} u.m = a;\}} if $f$ is named $m=$, except that iff \code{i dentical($o_1, o_2$)} then \cd{$o_1\#m=$ == $o_2\#m=$}.
4265 4356
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4346 The {\em closurization of method $f$ with respect to superclass $S$} is defined to be equivalent to: 4437 The {\em closurization of method $f$ with respect to superclass $S$} is defined to be equivalent to:
4347 4438
4348 \LMHash{} 4439 \LMHash{}
4349 \begin{itemize} 4440 \begin{itemize}
4350 \item $(a) \{\RETURN{}$ \SUPER{} $op$ $a;$\} if $f$ is named $op$ and $op$ is on e of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<< $, $>>$}. 4441 \item $(a) \{\RETURN{}$ \SUPER{} $op$ $a;$\} if $f$ is named $op$ and $op$ is on e of \code{$<$, $>$, $<$=, $>$=, ==, -, +, /, \~{}/, *, \%, $|$, \^{}, \&, $<< $, $>>$}.
4351 \item $() \{\RETURN{}$ \~{}\SUPER;\} if $f$ is named \~{}. 4442 \item $() \{\RETURN{}$ \~{}\SUPER;\} if $f$ is named \~{}.
4352 \item $(a) \{\RETURN{}$ $\SUPER[a];$\} if $f$ is named $[]$. 4443 \item $(a) \{\RETURN{}$ $\SUPER[a];$\} if $f$ is named $[]$.
4353 \item $(a, b) \{\RETURN{}$ $\SUPER[a] = b;$\} if $f$ is named $[]=$. 4444 \item $(a, b) \{\RETURN{}$ $\SUPER[a] = b;$\} if $f$ is named $[]=$.
4354 \item 4445 \item
4355 \begin{dartCode} 4446 \begin{dartCode}
4356 $(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{ 4447 $<T_1, \ldots, T_s>(r_1, \ldots, r_n, \{p_1 : d_1, \ldots , p_k : d_k\})$ \{
4357 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$ 4448 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1: p_1, \ldots, p_k: p_k);$
4358 \} 4449 \}
4359 \end{dartCode} 4450 \end{dartCode}
4360 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and named pa rameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. 4451 if $f$ is named $m$ and has type parameters $T_1, \ldots, T_s$, required para meters $r_1, \ldots, r_n$, and named parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
4361 \item 4452 \item
4362 \begin{dartCode} 4453 \begin{dartCode}
4363 $(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{ 4454 $<T_1, \ldots, T_s>(r_1, \ldots, r_n, [p_1 = d_1, \ldots , p_k = d_k])$\{
4364 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$; 4455 \RETURN{} \SUPER$.m(r_1, \ldots, r_n, p_1, \ldots, p_k)$;
4365 \} 4456 \}
4366 \end{dartCode} 4457 \end{dartCode}
4367 4458
4368 if $f$ is named $m$ and has required parameters $r_1, \ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$. 4459 if $f$ is named $m$ and has type parameters $T_1, \ldots, T_s$, required para meters $r_1, \ldots, r_n$, and optional positional parameters $p_1, \ldots, p_k$ with defaults $d_1, \ldots, d_k$.
4369 \end{itemize} 4460 \end{itemize}
4370 4461
4371 \LMHash{} 4462 \LMHash{}
4372 Except that iff two closurizations were created by code declared in the same cla ss with identical bindings of \THIS{} then \cd{\SUPER$_1\#m$ == \SUPER$_2\#m$}, \cd{\SUPER$_1.m$ == \SUPER$_2.m$}, \cd{\SUPER$_1\#m$ == \SUPER$_2.m$} and \cd {\SUPER$_1.m$ == \SUPER$_2\#m$}. 4463 Except that iff two closurizations were created by code declared in the same cla ss with identical bindings of \THIS{} then \cd{\SUPER$_1\#m$ == \SUPER$_2\#m$}, \cd{\SUPER$_1.m$ == \SUPER$_2.m$}, \cd{\SUPER$_1\#m$ == \SUPER$_2.m$} and \cd {\SUPER$_1.m$ == \SUPER$_2\#m$}.
4373 4464
4374 4465
4375 \LMHash{} 4466 \LMHash{}
4376 The {\em closurization of getter $f$ with respect to superclass $S$} is defined to be equivalent to \cd{()\{\RETURN{} \SUPER.m;\}} if $f$ is named $m$, except that iff two closurizations were created by code declared in the same class with identical bindings of \THIS{} then \cd{\SUPER$_1\#m$ == \SUPER$_2\#m$}. 4467 The {\em closurization of getter $f$ with respect to superclass $S$} is defined to be equivalent to \cd{()\{\RETURN{} \SUPER.m;\}} if $f$ is named $m$, except that iff two closurizations were created by code declared in the same class with identical bindings of \THIS{} then \cd{\SUPER$_1\#m$ == \SUPER$_2\#m$}.
4377 4468
4378 \LMHash{} 4469 \LMHash{}
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
4440 \LMHash{} 4531 \LMHash{}
4441 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$. 4532 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$.
4442 4533
4443 \LMHash{} 4534 \LMHash{}
4444 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : 4535 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that :
4445 \begin{itemize} 4536 \begin{itemize}
4446 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. 4537 \item \code{im.isSetter} evaluates to \code{\TRUE{}}.
4447 \item \code{im.memberName} evaluates to the symbol \code{v=}. 4538 \item \code{im.memberName} evaluates to the symbol \code{v=}.
4448 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_2$]}. 4539 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o_2$]}.
4449 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4540 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4541 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
4450 \end{itemize} 4542 \end{itemize}
4451 4543
4452 \LMHash{} 4544 \LMHash{}
4453 Then the method \code{noSuchMethod()} is looked up in $o_1$ and invoked with ar gument $im$. 4545 Then the method \code{noSuchMethod()} is looked up in $o_1$ and invoked with ar gument $im$.
4454 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 : 4546 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 :
4455 \begin{itemize} 4547 \begin{itemize}
4456 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. 4548 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}.
4457 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. 4549 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}.
4458 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. 4550 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$.
4459 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4551 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4552 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
4460 \end{itemize} 4553 \end{itemize}
4461 4554
4462 \LMHash{} 4555 \LMHash{}
4463 The value of the assignment expression is $o_2$ irrespective of whether setter l ookup has failed or succeeded. 4556 The value of the assignment expression is $o_2$ irrespective of whether setter l ookup has failed or succeeded.
4464 4557
4465 \LMHash{} 4558 \LMHash{}
4466 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$. 4559 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$.
4467 4560
4468 \LMHash{} 4561 \LMHash{}
4469 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: 4562 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:
(...skipping 14 matching lines...) Expand all
4484 Let $S$ be the superclass of the immediately enclosing class. 4577 Let $S$ be the superclass of the immediately enclosing class.
4485 The expression $e$ is evaluated to an object $o$. Then, the setter $v=$ is look ed up (\ref{getterAndSetterLookup}) in $S$ with respect to the current library. The body of $v=$ is executed with its formal parameter bound to $o$ and \THIS{ } bound to \THIS{}. 4578 The expression $e$ is evaluated to an object $o$. Then, the setter $v=$ is look ed up (\ref{getterAndSetterLookup}) in $S$ with respect to the current library. The body of $v=$ is executed with its formal parameter bound to $o$ and \THIS{ } bound to \THIS{}.
4486 4579
4487 \LMHash{} 4580 \LMHash{}
4488 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that : 4581 If the setter lookup has failed, then a new instance $im$ of the predefined cla ss \code{Invocation} is created, such that :
4489 \begin{itemize} 4582 \begin{itemize}
4490 \item \code{im.isSetter} evaluates to \code{\TRUE{}}. 4583 \item \code{im.isSetter} evaluates to \code{\TRUE{}}.
4491 \item \code{im.memberName} evaluates to the symbol \code{v=}. 4584 \item \code{im.memberName} evaluates to the symbol \code{v=}.
4492 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o$]}. 4585 \item \code{im.positionalArguments} evaluates to an immutable list with the same values as \code{[$o$]}.
4493 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4586 \item \code{im.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4587 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
4494 \end{itemize} 4588 \end{itemize}
4495 4589
4496 \LMHash{} 4590 \LMHash{}
4497 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked with argu ment $im$. 4591 Then the method \code{noSuchMethod()} is looked up in $S$ and invoked with argu ment $im$.
4498 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 \THIS{} with argument $im'$, where $im'$ is an instance of \code{Inv ocation} such that : 4592 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 \THIS{} with argument $im'$, where $im'$ is an instance of \code{Inv ocation} such that :
4499 \begin{itemize} 4593 \begin{itemize}
4500 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}. 4594 \item \code{im'.isMethod} evaluates to \code{\TRUE{}}.
4501 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}. 4595 \item \code{im'.memberName} evaluates to \code{\#noSuchMethod}.
4502 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$. 4596 \item \code{im'.positionalArguments} evaluates to an immutable list whose sole e lement is $im$.
4503 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}. 4597 \item \code{im'.namedArguments} evaluates to the value of \code{\CONST{} \{\}}.
4598 \item \code{im.typeArguments} evaluates to the value of \code{\CONST{} []}.
4504 \end{itemize} 4599 \end{itemize}
4505 4600
4506 \LMHash{} 4601 \LMHash{}
4507 The value of the assignment expression is $o$ irrespective of whether setter loo kup has failed or succeeded. 4602 The value of the assignment expression is $o$ irrespective of whether setter loo kup has failed or succeeded.
4508 4603
4509 \LMHash{} 4604 \LMHash{}
4510 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 of $S.v$. 4605 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 of $S.v$.
4511 4606
4512 \LMHash{} 4607 \LMHash{}
4513 It is a static type warning if $S$ does not have an accessible instance setter n amed $v=$ unless $S$ or a superinterface of $S$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \code{dar t:core}. 4608 It is a static type warning if $S$ does not have an accessible instance setter n amed $v=$ unless $S$ or a superinterface of $S$ is annotated with an annotation denoting a constant identical to the constant \code{@proxy} defined in \code{dar t:core}.
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
5009 \end{grammar} 5104 \end{grammar}
5010 5105
5011 \LMHash{} 5106 \LMHash{}
5012 A {\em postfix expression} is either a primary expression, a function, method o r getter invocation, or an invocation of a postfix operator on an expression $e$ . 5107 A {\em postfix expression} is either a primary expression, a function, method o r getter invocation, or an invocation of a postfix operator on an expression $e$ .
5013 5108
5014 \LMHash{} 5109 \LMHash{}
5015 A postfix expression of the form \code{$v$++}, where $v$ is an identifier, is eq uivalent to \code{()\{var r = $v$; $v$ = r + 1; return r\}()}. 5110 A postfix expression of the form \code{$v$++}, where $v$ is an identifier, is eq uivalent to \code{()\{var r = $v$; $v$ = r + 1; return r\}()}.
5016 5111
5017 \rationale{The above ensures that if $v$ is a field, the getter gets called exac tly once. Likewise in the cases below. 5112 \rationale{The above ensures that if $v$ is a field, the getter gets called exac tly once. Likewise in the cases below.
5018 } 5113 }
5019 %what about e?.x++
5020 5114
5021 \LMHash{} 5115 \LMHash{}
5022 A postfix expression of the form \code{$C.v$ ++} is equivalent to 5116 A postfix expression of the form \code{$C.v$ ++} is equivalent to
5023 5117
5024 \code{()\{var r = $C.v$; $C.v$ = r + 1; return r\}()}. 5118 \code{()\{var r = $C.v$; $C.v$ = r + 1; return r\}()}.
5025 5119
5026 \LMHash{} 5120 \LMHash{}
5027 A postfix expression of the form \code{$e_1.v$++} is equivalent to 5121 A postfix expression of the form \code{$e_1.v$++} is equivalent to
5028 5122
5029 \code{(x)\{var r = x.v; x.v = r + 1; \RETURN{} r\}($e_1$)}. 5123 \code{(x)\{var r = x.v; x.v = r + 1; \RETURN{} r\}($e_1$)}.
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
6900 \rationale{ 6994 \rationale{
6901 The interpretation of URIs is mostly left to the surrounding computing environm ent. For example, if Dart is running in a web browser, that browser will likely interpret some URIs. While it might seem attractive to specify, say, that URIs a re interpreted with respect to a standard such as IETF RFC 3986, in practice thi s will usually depend on the browser and cannot be relied upon. 6995 The interpretation of URIs is mostly left to the surrounding computing environm ent. For example, if Dart is running in a web browser, that browser will likely interpret some URIs. While it might seem attractive to specify, say, that URIs a re interpreted with respect to a standard such as IETF RFC 3986, in practice thi s will usually depend on the browser and cannot be relied upon.
6902 } 6996 }
6903 6997
6904 \LMHash{} 6998 \LMHash{}
6905 A URI of the form \code{dart:$s$} is interpreted as a reference to a system libr ary (\ref{imports}) $s$. 6999 A URI of the form \code{dart:$s$} is interpreted as a reference to a system libr ary (\ref{imports}) $s$.
6906 7000
6907 \LMHash{} 7001 \LMHash{}
6908 A URI of the form \code{package:$s$} is interpreted in an implementation specifi c manner. 7002 A URI of the form \code{package:$s$} is interpreted in an implementation specifi c manner.
6909 7003
7004 \commentary{
7005 This location will often be the location of the root library presented to the Da rt compiler. However, implementations may supply means to override or replace th is choice.
7006 }
7007
6910 \rationale{ 7008 \rationale{
6911 The intent is that, during development, Dart programmers can rely on a package m anager to find elements of their program. 7009 The intent is that, during development, Dart programmers can rely on a package m anager to find elements of their program.
6912 } 7010 }
6913 7011
6914 \LMHash{} 7012 \LMHash{}
6915 Otherwise, any relative URI is interpreted as relative to the the location of th e current library. All further interpretation of URIs is implementation dependen t. 7013 Otherwise, any relative URI is interpreted as relative to the the location of th e current library. All further interpretation of URIs is implementation dependen t.
6916 7014
6917 \commentary{This means it is dependent on the embedder.} 7015 \commentary{This means it is dependent on the embedder.}
6918 7016
6919 7017
6920 \section{Types} 7018 \section{Types}
6921 \LMLabel{types} 7019 \LMLabel{types}
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
7200 An interface type $T$ may be assigned to a type $S$, written $T \Longleftrighta rrow S$, iff either $T <: S$ or $S <: T$. 7298 An interface type $T$ may be assigned to a type $S$, written $T \Longleftrighta rrow S$, iff either $T <: S$ or $S <: T$.
7201 7299
7202 \rationale{This rule may surprise readers accustomed to conventional typecheckin g. The intent of the $\Longleftrightarrow$ relation is not to ensure that an ass ignment is correct. Instead, it aims to only flag assignments that are almost ce rtain to be erroneous, without precluding assignments that may work. 7300 \rationale{This rule may surprise readers accustomed to conventional typecheckin g. The intent of the $\Longleftrightarrow$ relation is not to ensure that an ass ignment is correct. Instead, it aims to only flag assignments that are almost ce rtain to be erroneous, without precluding assignments that may work.
7203 7301
7204 For example, assigning a value of static type Object to a variable with static t ype String, while not guaranteed to be correct, might be fine if the runtime val ue happens to be a string. 7302 For example, assigning a value of static type Object to a variable with static t ype String, while not guaranteed to be correct, might be fine if the runtime val ue happens to be a string.
7205 } 7303 }
7206 7304
7207 \subsection{Function Types} 7305 \subsection{Function Types}
7208 \LMLabel{functionTypes} 7306 \LMLabel{functionTypes}
7209 7307
7308 \subsubsection{Ordinary Function Types}
7309 \LMLabel{ordinaryFunctionTypes}
7310
7210 \LMHash{} 7311 \LMHash{}
7211 Function types come in two variants: 7312 Function types come in two variants:
7212 \begin{enumerate} 7313 \begin{enumerate}
7213 \item 7314 \item
7214 The types of functions that only have positional parameters. These have the gen eral form $(T_1, \ldots, T_n, [T_{n+1} \ldots, T_{n+k}]) \rightarrow T$. 7315 The types of functions that only have positional parameters. These have the gen eral form $(T_1, \ldots, T_n, [T_{n+1} \ldots, T_{n+k}]) \rightarrow T$.
7215 \item 7316 \item
7216 The types of functions with named parameters. These have the general form $(T_1 , \ldots, T_n, \{T_{x_1}$ $x_1 \ldots, T_{x_k}$ $x_k\}) \rightarrow T$. 7317 The types of functions with named parameters. These have the general form $(T_1 , \ldots, T_n, \{T_{x_1}$ $x_1 \ldots, T_{x_k}$ $x_k\}) \rightarrow T$.
7217 \end{enumerate} 7318 \end{enumerate}
7218 7319
7219 %$(T_1, \ldots T_n) \rightarrow T$ is a subtype of $(S_1, \ldots, S_n, ) \right arrow S$, if all of the following conditions are met: 7320 %$(T_1, \ldots T_n) \rightarrow T$ is a subtype of $(S_1, \ldots, S_n, ) \right arrow S$, if all of the following conditions are met:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
7316 \end{itemize} 7417 \end{itemize}
7317 \item $\forall i \in 1 .. n, T_i << S_i$. 7418 \item $\forall i \in 1 .. n, T_i << S_i$.
7318 \item $k \ge m$ and $y_i \in \{x_1, \ldots, x_k\}, i \in 1 .. m$. 7419 \item $k \ge m$ and $y_i \in \{x_1, \ldots, x_k\}, i \in 1 .. m$.
7319 %\{x_1, \ldots, x_k\}$ is a superset of $\{y_1, \ldots, y_m\}$. 7420 %\{x_1, \ldots, x_k\}$ is a superset of $\{y_1, \ldots, y_m\}$.
7320 \item For all $y_i \in \{y_1, \ldots, y_m\}, y_i = x_j \Rightarrow T_j << S_i$ 7421 \item For all $y_i \in \{y_1, \ldots, y_m\}, y_i = x_j \Rightarrow T_j << S_i$
7321 \end{enumerate} 7422 \end{enumerate}
7322 7423
7323 \LMHash{} 7424 \LMHash{}
7324 Furthermore, if $F$ is a function type, $F << \code{Function}$. 7425 Furthermore, if $F$ is a function type, $F << \code{Function}$.
7325 7426
7427 \subsubsection{Generic Function Types}
Leaf 2015/06/16 23:23:10 This is missing the treatment of assignability and
7428 \LMLabel{genericFunctionTypes} %generics
7429
7430
7431 A generic function type has the form $\forall T_1 <: B_1, \ldots, T_k <: B_k. F $ where $F$ is an ordinary function type.
7432
7433 Let $G_1 = \forall S_1 <: B_1, \ldots, S_k <: B_k. F_1$ and $G_2 = \forall T_1 <: C_1, \ldots, T_k <: C_k. F_2$. Then $G_1 <: G_2$ iff $B_i <: C_i$ and $F_1 <: [S_i/T_i] F_2, i \in 1 .. k$.
7434
7435 \rationale{
7436 The rule is covariant, in keeping with Dart's other rules for generics, and for the same reasons.
7437
7438 }
7439
7440 A generic function type $G = \forall T_1 <: B_1, \ldots, T_k <: B_k. F$ is a su btype of an ordinary function type $F'$ iff $[\DYNAMIC/T_i] F <: F', i \in 1 .. k$.
7441
7442 \rationale{
Leaf 2015/06/16 23:23:10 Just as an aside, I think this is a fairly natural
gbracha 2015/06/18 20:05:58 That's an interesting point. AFIK, most type syste
Leaf 2015/06/23 01:59:59 I don't know specifically with object subtyping.
7443 It is essential that a generic function may be used without the arguments. Dart , by design, never insists on the use of type information. So even if a function is declared with type parameters, users of the function must be free to call it without type arguments.
7444
7445 Even if we did not insist on the former point on principle,, there are many func tions in the Dart libraries that would benefit from the use of type parameters. If these are to be changed, it is also crucial for compatibility that their cal lers may continue to use them without type arguments.
Leaf 2015/06/16 23:23:10 Double comma after "principle".
gbracha 2015/06/18 20:05:59 Done.
7446
7447 In light of the broad arguments given in the two preceding paragraphs, we can no w explain the above type rule in detail. When used without actual type arguments , the generic function will use type \DYNAMIC{} as the default value for its typ e parameters. Hence, if we substitute \DYNAMIC{} for all uses of the formal type parameters in the generic function type and the resulting function type is a su btype of an ordinary function type, we are assured the generic function can be u sed in place of the non-generic one.
7448 }
7449
7450 {\bf Hypothetical:}
7451
7452 An ordinary function $F$ is a subtype of a generic function $G = \forall T_1 <: B_1, \ldots, T_k <: B_k. F'$ iff $F <: [B_i/T_i] F'$.
7453
7454 \rationale{
7455
7456 It would be extremely attractive to have this rule, allowing ordinary functions to be used where generic functions are expected. The motivation here would also be compatibility. If an existing method were converted to be generic, subclasses and implementors would no longer be valid. At the very least, their declaration s would now provoke warnings. Worse, if existing uses of such APIs evolved to p ass actual type arguments, the code would crash.
Leaf 2015/06/16 23:23:10 I agree with the motivation for wanting this, but
gbracha 2015/06/18 20:05:58 Yes, I realize it's rather costly. The choice is h
Leaf 2015/06/23 01:59:59 Fair enough. I obviously fall in the error checki
7457
7458 This leads to the proposed rule above.
7459 }
7460
7461
7326 7462
7327 \subsection{Type \DYNAMIC{}} 7463 \subsection{Type \DYNAMIC{}}
7328 \LMLabel{typeDynamic} 7464 \LMLabel{typeDynamic}
7329 7465
7330 \LMHash{} 7466 \LMHash{}
7331 The type \DYNAMIC{} denotes the unknown type. 7467 The type \DYNAMIC{} denotes the unknown type.
7332 7468
7333 \LMHash{} 7469 \LMHash{}
7334 If no static type annotation has been provided the type system assumes the decla ration has the unknown type. If a generic type is used but type arguments are no t provided, then the type arguments default to the unknown type. 7470 If no static type annotation has been provided the type system assumes the decla ration has the unknown type. If a generic type is used but type arguments are no t provided, then the type arguments default to the unknown type.
7335 7471
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
7464 The least upper bound of \VOID{} and any type $T \ne \DYNAMIC{}$ is \VOID{}. 7600 The least upper bound of \VOID{} and any type $T \ne \DYNAMIC{}$ is \VOID{}.
7465 Let $U$ be a type variable with upper bound $B$. The least upper bound of $U$ an d a type $T$ is the least upper bound of $B$ and $T$. 7601 Let $U$ be a type variable with upper bound $B$. The least upper bound of $U$ an d a type $T$ is the least upper bound of $B$ and $T$.
7466 7602
7467 \LMHash{} 7603 \LMHash{}
7468 The least upper bound relation is symmetric and reflexive. 7604 The least upper bound relation is symmetric and reflexive.
7469 7605
7470 % Function types 7606 % Function types
7471 7607
7472 \LMHash{} 7608 \LMHash{}
7473 The least upper bound of a function type and an interface type $T$ is the least upper bound of \cd{Function} and $T$. 7609 The least upper bound of a function type and an interface type $T$ is the least upper bound of \cd{Function} and $T$.
7474 Let $F$ and $G$ be function types. If $F$ and $G$ differ in their number of requ ired parameters, then the least upper bound of $F$ and $G$ is \cd{Function}. Ot herwise: 7610 Let $F$ and $G$ be function types. If $F$ and $G$ differ in their number of requ ired parameters, then the least upper bound of $F$ and $G$ is \cd{Function}. Oth erwise:
7475 \begin{itemize} 7611 \begin{itemize}
7476 \item If 7612 \item If
7477 7613
7478 $F= (T_1 \ldots T_r, [T_{r+1}, \ldots, T_n]) \longrightarrow T_0$, 7614 $F= (T_1 \ldots T_r, [T_{r+1}, \ldots, T_n]) \longrightarrow T_0$,
7479 7615
7480 $G= (S_1 \ldots S_r, [S_{r+1}, \ldots, S_k]) \longrightarrow S_0$ 7616 $G= (S_1 \ldots S_r, [S_{r+1}, \ldots, S_k]) \longrightarrow S_0$
7481 7617
7482 where $k \le n$ then the least upper bound of $F$ and $G$ is 7618 where $k \le n$ then the least upper bound of $F$ and $G$ is
7483 7619
7484 $(L_1 \ldots L_r, [L_{r+1}, \ldots, L_k]) \longrightarrow L_0$ 7620 $(L_1 \ldots L_r, [L_{r+1}, \ldots, L_k]) \longrightarrow L_0$
7485 7621
7486 where $L_i$ is the least upper bound of $T_i$ and $S_i, i \in 0..k$. 7622 where $L_i$ is the least upper bound of $T_i$ and $S_i, i \in 0..k$.
7487 \item If 7623 \item If
7488 7624
7489 $F= (T_1 \ldots T_r, [T_{r+1}, \ldots, T_n]) \longrightarrow T_0$, 7625 $F= (T_1 \ldots T_r, [T_{r+1}, \ldots, T_n]) \longrightarrow T_0$,
7490 7626
7491 $G= (S_1 \ldots S_r, \{ \ldots \}) \longrightarrow S_0$ 7627 $G= (S_1 \ldots S_r, \{ \ldots \}) \longrightarrow S_0$
7492 7628
7493 then the least upper bound of $F$ and $G$ is 7629 then the least upper bound of $F$ and $G$ is
7494 7630
7495 $(L_1 \ldots L_r) \longrightarrow L_0$ 7631 $(L_1 \ldots L_r) \longrightarrow L_0$
7496 7632
7497 where $L_i$ 7633 where $L_i$
7498 is the least upper bound of $T_i$ and $S_i, i \in 0..r$. 7634 is the least upper bound of $T_i$ and $S_i, i \in 0..r$.
7499 \item If 7635 \item If
7500 7636
7501 $F= (T_1 \ldots T_r, \{T_{r+1}$ $p_{r+1}, \ldots, T_f$ $p_f\}) \longrightarrow T_0$, 7637 $F= (T_1 \ldots T_r, \{T_{r+1}$ $p_{r+1}, \ldots, T_f$ $p_f\}) \longrightarrow T_0$,
7502 7638
7503 $G= (S_1 \ldots S_r, \{ S_{r+1}$ $q_{r+1}, \ldots, S_g$ $q_g\}) \longrightarrow S_0$ 7639 $G= (S_1 \ldots S_r, \{ S_{r+1}$ $q_{r+1}, \ldots, S_g$ $q_g\}) \longrightarrow S_0$
7504 7640
7505 then let $\{x_m, \ldots x_n\} = \{p_{r+1}, \ldots, p_f\} \cap \{q_{r+1}, \ldots , q_g\}$ and let $X_j$ be the least upper bound of the types of $x_j$ in $F$ and $G, j \in m..n$. Then 7641 then let $\{x_m, \ldots x_n\} = \{p_{r+1}, \ldots, p_f\} \cap \{q_{r+1}, \ldots , q_g\}$ and let $X_j$ be the least upper bound of the types of $x_j$ in $F$ and $G, j \in m..n$. Then
7506 the least upper bound of $F$ and $G$ is 7642 the least upper bound of $F$ and $G$ is
7507 7643
7508 $(L_1 \ldots L_r, \{ X_m$ $x_m, \ldots, X_n$ $x_n\}) \longrightarrow L_0$ 7644 $(L_1 \ldots L_r, \{ X_m$ $x_m, \ldots, X_n$ $x_n\}) \longrightarrow L_0$
7509 7645
7510 where $L_i$ is the least upper bound of $T_i$ and $S_i, i \in 0..r$ 7646 where $L_i$ is the least upper bound of $T_i$ and $S_i, i \in 0..r$
7647
7648 \item If
Leaf 2015/06/16 23:23:10 I think this is wrong. It's not symmetric, and I
gbracha 2015/06/18 20:05:59 Yes, the asymmetry is a problem.
Leaf 2015/06/23 01:59:59 I think a reasonable definition might be to define
7649
7650 $F = \forall P_1 <: B_1, \ldots, P_n <: B_m. fsig$
7651
7652 $G = \forall Q_1 <: C_1, \ldots, Q_n <: C_m. gsig$
7653
7654 then
7655 the least upper bound of $F$ and $G$ is
7656 $\forall P_1 <: L_1, \ldots, P_n <: L_n. lsig$ where
7657 $L_i$ is the least upper bound of $B_i$ and $[P_i/Q_i]C_i, i \in 1..n$ and $lsig $ is the least upper bound of $fsig$ and $[P_i/Q_i]gsig$.
7658
7659
7660 \item If
7661
7662 $F = \forall P_1 <: B_1, \ldots, P_n <: B_m. fsig$
7663
7664 $G = \forall Q_1 <: C_1, \ldots, Q_m <: C_m. gsig$
7665
7666 where $n \ne m$, then
7667 the least upper bound of $F$ and $G$ is the least upper bound of
7668 $[B_i/P_i]fsig, i \in 1..n$ and $[C_j/Q_j]gsig, j \in 1..m$.
7669
7670 \item
7671 $F = \forall P_1 <: B_1, \ldots, P_m <: B_m. fsig$
7672
7673 $G = gsig$
7674 then
7675 the least upper bound of $F$ and $G$ is the least upper bound of $[B_i/P_i]fsig, i \in 1..n$ and $gsig$.
7676
7511 \end{itemize} 7677 \end{itemize}
7512 7678
7513 7679
7514 \section{Reference} 7680 \section{Reference}
7515 \LMLabel{reference} 7681 \LMLabel{reference}
7516 7682
7517 \subsection{Lexical Rules} 7683 \subsection{Lexical Rules}
7518 \LMLabel{lexicalRules} 7684 \LMLabel{lexicalRules}
7519 7685
7520 \LMHash{} 7686 \LMHash{}
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
7797 7963
7798 The invariant that each normative paragraph is associated with a line 7964 The invariant that each normative paragraph is associated with a line
7799 containing the text \LMHash{} should be maintained. Extra occurrences 7965 containing the text \LMHash{} should be maintained. Extra occurrences
7800 of \LMHash{} can be added if needed, e.g., in order to make 7966 of \LMHash{} can be added if needed, e.g., in order to make
7801 individual \item{}s in itemized lists addressable. Each \LM.. command 7967 individual \item{}s in itemized lists addressable. Each \LM.. command
7802 must occur on a separate line. \LMHash{} must occur immediately 7968 must occur on a separate line. \LMHash{} must occur immediately
7803 before the associated paragraph, and \LMLabel must occur immediately 7969 before the associated paragraph, and \LMLabel must occur immediately
7804 after the associated \section{}, \subsection{} etc. 7970 after the associated \section{}, \subsection{} etc.
7805 7971
7806 ---------------------------------------------------------------------- 7972 ----------------------------------------------------------------------
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698