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

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

Issue 27209004: Least upper bound fixes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 \documentclass{article} 1 \documentclass{article}
2 \usepackage{epsfig} 2 \usepackage{epsfig}
3 \usepackage{dart} 3 \usepackage{dart}
4 \usepackage{bnf} 4 \usepackage{bnf}
5 \usepackage{hyperref} 5 \usepackage{hyperref}
6 \newcommand{\code}[1]{{\sf #1}} 6 \newcommand{\code}[1]{{\sf #1}}
7 \title{Dart Programming Language Specification \\ 7 \title{Dart Programming Language Specification \\
8 {\large Draft Version 0.70}} 8 {\large Draft Version 0.71}}
9 \author{The Dart Team} 9 \author{The Dart Team}
10 \begin{document} 10 \begin{document}
11 \maketitle 11 \maketitle
12 12
13 \tableofcontents 13 \tableofcontents
14 14
15 \newpage 15 \newpage
16 16
17 \pagestyle{myheadings} 17 \pagestyle{myheadings}
18 \markright{{\bf Draft} Dart Programming Language Specification {\bf Draft}} 18 \markright{{\bf Draft} Dart Programming Language Specification {\bf Draft}}
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 \ref{try}: \ON{} with no \CATCH{} implies \DYNAMIC{}, not \cd{Object}. 502 \ref{try}: \ON{} with no \CATCH{} implies \DYNAMIC{}, not \cd{Object}.
503 503
504 \ref{return}: Added warning if \RETURN{} without expression mixed with \RETURN{} with an expression. 504 \ref{return}: Added warning if \RETURN{} without expression mixed with \RETURN{} with an expression.
505 505
506 \ref{exports}: Ensure that exports treat \code{dart:} libs specially, like impor ts do. 506 \ref{exports}: Ensure that exports treat \code{dart:} libs specially, like impor ts do.
507 507
508 \ref{typePromotion}: Added notion of type promotion. 508 \ref{typePromotion}: Added notion of type promotion.
509 509
510 \ref{typedef}: Banned all recursion in typedefs. 510 \ref{typedef}: Banned all recursion in typedefs.
511 511
512 \subsubsection{Changes Since Version 0.7}
513
514 \ref{leastUpperBounds}: Extended LUBs to all types.
515
516
512 517
513 \section{Notation} 518 \section{Notation}
514 \label{notation} 519 \label{notation}
515 520
516 We distinguish between normative and non-normative text. Normative text defines the rules of Dart. It is given in this font. At this time, non-normative text in cludes: 521 We distinguish between normative and non-normative text. Normative text defines the rules of Dart. It is given in this font. At this time, non-normative text in cludes:
517 \begin{itemize} 522 \begin{itemize}
518 \item[Rationale] Discussion of the motivation for language design decisions appe ars in italics. \rationale{Distinguishing normative from non-normative helps cla rify what part of the text is binding and what part is merely expository.} 523 \item[Rationale] Discussion of the motivation for language design decisions appe ars in italics. \rationale{Distinguishing normative from non-normative helps cla rify what part of the text is binding and what part is merely expository.}
519 \item[Commentary] Comments such as ``\commentary{The careful reader will have n oticed that the name Dart has four characters}'' serve to illustrate or clarify the specification, but are redundant with the normative text. \commentary{The d ifference between commentary and rationale can be subtle.} \rationale{ Commentar y is more general than rationale, and may include illustrative examples or clari fications. } 524 \item[Commentary] Comments such as ``\commentary{The careful reader will have n oticed that the name Dart has four characters}'' serve to illustrate or clarify the specification, but are redundant with the normative text. \commentary{The d ifference between commentary and rationale can be subtle.} \rationale{ Commentar y is more general than rationale, and may include illustrative examples or clari fications. }
520 \item[Open questions] (\Q{in this font}). Open questions are points that are uns ettled in the mind of the author(s) of the specification; expect them (the quest ions, not the authors; precision is important in a specification) to be eliminat ed in the final specification. \Q{Should the text at the end of the previous bul let be rationale or commentary?} 525 \item[Open questions] (\Q{in this font}). Open questions are points that are uns ettled in the mind of the author(s) of the specification; expect them (the quest ions, not the authors; precision is important in a specification) to be eliminat ed in the final specification. \Q{Should the text at the end of the previous bul let be rationale or commentary?}
521 \end{itemize} 526 \end{itemize}
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 a class that is explicitly declared with the \ABSTRACT{} modifier, either by m eans of a class declaration or via a type alias (\ref{typedef}) for a mixin appl ication (\ref{mixinApplication}). A {\em concrete class} is a class that is not abstract. 1211 a class that is explicitly declared with the \ABSTRACT{} modifier, either by m eans of a class declaration or via a type alias (\ref{typedef}) for a mixin appl ication (\ref{mixinApplication}). A {\em concrete class} is a class that is not abstract.
1207 %, or a class that declares at least one abstract method (\ref{abstractInstance Members}). 1212 %, or a class that declares at least one abstract method (\ref{abstractInstance Members}).
1208 1213
1209 \rationale{ 1214 \rationale{
1210 %The abstract modifier for classes is intended to be used in scenarios where an abstract class $A$ inherits from another abstract class $B$. In such a situation , it may be that A$ $itself does not declare any abstract methods. In the absenc e of an abstract modifier on the class, the class would be interpreted as a conc rete class. However, w 1215 %The abstract modifier for classes is intended to be used in scenarios where an abstract class $A$ inherits from another abstract class $B$. In such a situation , it may be that A$ $itself does not declare any abstract methods. In the absenc e of an abstract modifier on the class, the class would be interpreted as a conc rete class. However, w
1211 We want different behavior for concrete classes and abstract classes. If $A$ is intended to be abstract, we want the static checker to warn about any attempt to instantiate $A$, and we do not want the checker to complain about unimplemented methods in $A$. In contrast, if $A$ is intended to be concrete, the checker sho uld warn about all unimplemented methods, but allow clients to instantiate it fr eely. 1216 We want different behavior for concrete classes and abstract classes. If $A$ is intended to be abstract, we want the static checker to warn about any attempt to instantiate $A$, and we do not want the checker to complain about unimplemented methods in $A$. In contrast, if $A$ is intended to be concrete, the checker sho uld warn about all unimplemented methods, but allow clients to instantiate it fr eely.
1212 } 1217 }
1213 1218
1214 The {\em interface of class $C$} is an implicit interface that declares instance members that correspond to the instance members declared by $C$, and whose dire ct superinterfaces are the direct superinterfaces of $C$ (\ref{superinterfaces}) . When a class name appears as a type, that name denotes the interface of the cl ass. 1219 The {\em interface of class $C$} is an implicit interface that declares instance members that correspond to the instance members declared by $C$, and whose dire ct superinterfaces are the direct superinterfaces of $C$ (\ref{superinterfaces}) . When a class name appears as a type, that name denotes the interface of the cl ass.
1215 1220
1221 % making an exception for the setters generated for final fields is tempting but problematic.
1222 % If a super type defines a setter, it will be overridden yet have no impact on the interface.
1223 % Maybe the final field hides the setter in scope?
1224 % I think the original rules were best.
1225
1216 It is a compile-time error if a class declares two members of the same name. 1226 It is a compile-time error if a class declares two members of the same name.
1217 %, except that a getter and a setter may be declared with the same name provide d both are instance members or both are static members. 1227 %, except that a getter and a setter may be declared with the same name provide d both are instance members or both are static members.
1218 It is a compile-time error if a class has an instance member and a static member with the same name. 1228 It is a compile-time error if a class has an instance member and a static member with the same name.
1219 % It is a compile-time error if a generic (\ref{generics}) class declares a memb er with the same name as one of its type parameters. 1229 % It is a compile-time error if a generic (\ref{generics}) class declares a memb er with the same name as one of its type parameters.
1220 1230
1221 \commentary{Here are simple examples, that illustrate the difference between ``h as a member'' and ``declares a member''. For example, \code{B} {\em declares} on e member named \code{f}, but {\em has} two such members. The rules of inheritanc e determine what members a class has. 1231 \commentary{Here are simple examples, that illustrate the difference between ``h as a member'' and ``declares a member''. For example, \code{B} {\em declares} on e member named \code{f}, but {\em has} two such members. The rules of inheritanc e determine what members a class has.
1222 } 1232 }
1223 1233
1224 \begin{dartCode} 1234 \begin{dartCode}
1225 \CLASS{} A \{ 1235 \CLASS{} A \{
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 %\VOID{} \SET{} $v=(T$ $x)$ 1459 %\VOID{} \SET{} $v=(T$ $x)$
1450 1460
1451 %whose execution sets the value of $v$ to the incoming argument $x$. 1461 %whose execution sets the value of $v$ to the incoming argument $x$.
1452 1462
1453 %A non-final instance variable declaration of the form \code{\VAR{} $v$;} or th e form \code{\VAR{} $v$ = $e$;} always induces an implicit setter function wi th signature 1463 %A non-final instance variable declaration of the form \code{\VAR{} $v$;} or th e form \code{\VAR{} $v$ = $e$;} always induces an implicit setter function wi th signature
1454 1464
1455 %\SET{} $v=(x)$ 1465 %\SET{} $v=(x)$
1456 1466
1457 %whose execution sets the value of $v$ to the incoming argument $x$. 1467 %whose execution sets the value of $v$ to the incoming argument $x$.
1458 1468
1469 % It is a compile-time error/warning if a a class $C$ declares a final instance variable $v$ and $C$ inherits a setter $v=$.
1470
1459 1471
1460 \subsection{Constructors} 1472 \subsection{Constructors}
1461 \label{constructors} 1473 \label{constructors}
1462 1474
1463 A {\em constructor} is a special function that is used in instance creation expr essions (\ref{instanceCreation}) to produce objects. Constructors may be generat ive (\ref{generativeConstructors}) or they may be factories (\ref{factories}). 1475 A {\em constructor} is a special function that is used in instance creation expr essions (\ref{instanceCreation}) to produce objects. Constructors may be generat ive (\ref{generativeConstructors}) or they may be factories (\ref{factories}).
1464 1476
1465 A {\em constructor name} always begins with the name of its immediately enclosin g class, and may optionally be followed by a dot and an identifier $id$. It is a compile-time error if $id$ is the name of a member declared in the immediately enclosing class. It is a compile-time error if the name of a constructor is no t a constructor name. 1477 A {\em constructor name} always begins with the name of its immediately enclosin g class, and may optionally be followed by a dot and an identifier $id$. It is a compile-time error if $id$ is the name of a member declared in the immediately enclosing class. It is a compile-time error if the name of a constructor is no t a constructor name.
1466 1478
1467 1479
1468 % In what scope do constructors go? The simple names of named constructors go i n the static scope of the class. Unnamed ones go nowhere, but we use the class n ame to refer to them; the class name could also in the static scope of the class as well to prevent weird errors, or we could ban it explicitly and avoiding dup lication. Similarly, the instance scope could contain the constructor names and class name, or we could have special rules to prevent collisions between instanc e members and constructors or the class. 1480 % In what scope do constructors go? The simple names of named constructors go i n the static scope of the class. Unnamed ones go nowhere, but we use the class n ame to refer to them; the class name could also in the static scope of the class as well to prevent weird errors, or we could ban it explicitly and avoiding dup lication. Similarly, the instance scope could contain the constructor names and class name, or we could have special rules to prevent collisions between instanc e members and constructors or the class.
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 \item $m^\prime$ has the same name as $m$. 2131 \item $m^\prime$ has the same name as $m$.
2120 \item $m^\prime$ is accessible to $K$. 2132 \item $m^\prime$ is accessible to $K$.
2121 \item $A$ is a direct superinterface of $J$ and either 2133 \item $A$ is a direct superinterface of $J$ and either
2122 \begin{itemize} 2134 \begin{itemize}
2123 \item $m^\prime$ is a member of $A$ or 2135 \item $m^\prime$ is a member of $A$ or
2124 \item $m^\prime$ is a member of $inherited(A, K)$. 2136 \item $m^\prime$ is a member of $inherited(A, K)$.
2125 \end{itemize} 2137 \end{itemize}
2126 \end{itemize} 2138 \end{itemize}
2127 2139
2128 2140
2129 Let $I$ be the implicit interface of a class $C$ declared in library $L$. $I$ { \em inherits} all members of $inherited(I, L)$ and $I$ {\em overrides} $m^\prime $ if $m^\prime \in overrides(I, L)$. 2141 Let $I$ be the implicit interface of a class $C$ declared in library $L$. $I$ { \em inherits} all members of $inherited(I, L)$ and $I$ {\em overrides} $m^\prime $ if $m^\prime \in overrides(I, L)$. It is a static warning if $m$ is a method and $m^\prime$ is a getter, or if $m$ is a getter and $m^\prime$ is a method.
2130 2142
2131 2143
2132 %Let $I = S_0$ be the implicit interface of a class $C$ declared in library $L$, and let $\{S_1 \ldots S_k\}$ be the set of all superinterfaces of $I$. 2144 %Let $I = S_0$ be the implicit interface of a class $C$ declared in library $L$, and let $\{S_1 \ldots S_k\}$ be the set of all superinterfaces of $I$.
2133 2145
2134 %Let $I$ be the implicit interface of a class $C$. $I$ inherits any instance me mbers of its superinterfaces that are not overridden by members declared in $C$. 2146 %Let $I$ be the implicit interface of a class $C$. $I$ inherits any instance me mbers of its superinterfaces that are not overridden by members declared in $C$.
2135 2147
2136 % tighten definition? do we need chain as for classes? Definition for interface override? 2148 % tighten definition? do we need chain as for classes? Definition for interface override?
2137 2149
2138 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. 2150 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.
2139 2151
2140 %If some but not all of the $m_i, 1 \le i \le k$ are getters, or if some but not all of the $m_i$ are setters, none of the $m_i$ are inherited, and a static war ning is issued. 2152 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.
2141 2153
2142 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: 2154 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:
2143 \begin{itemize} 2155 \begin{itemize}
2144 \item Let $numberOfPositionals(f)$ denote the number of positional parameters of a function $f$, and let $numberOfRequiredParams(f)$ denote the number of requir ed parameters of a function $f$. Furthermore, let $s$ denote the set of all name d parameters of the $m_1, \ldots, m_k$. Then let 2156 \item Let $numberOfPositionals(f)$ denote the number of positional parameters of a function $f$, and let $numberOfRequiredParams(f)$ denote the number of requir ed parameters of a function $f$. Furthermore, let $s$ denote the set of all name d parameters of the $m_1, \ldots, m_k$. Then let
2145 2157
2146 $h = max(numberOfPositionals(m_i)), $ 2158 $h = max(numberOfPositionals(m_i)), $
2147 2159
2148 $r = min(numberOfRequiredParams(m_i)), i \in 1..k$. 2160 $r = min(numberOfRequiredParams(m_i)), i \in 1..k$.
2149 2161
2150 If $r \le h$ then $I$ has a method named $n$, with $r$ required parameters of ty pe \DYNAMIC{}, $h$ positional parameters of type \DYNAMIC{}, named parameters $ s$ of type \DYNAMIC{} and return type \DYNAMIC{}. 2162 If $r \le h$ then $I$ has a method named $n$, with $r$ required parameters of ty pe \DYNAMIC{}, $h$ positional parameters of type \DYNAMIC{}, named parameters $ s$ of type \DYNAMIC{} and return type \DYNAMIC{}.
2151 \item Otherwise none of the members $m_1, \ldots, m_k$ is inherited. 2163 \item Otherwise none of the members $m_1, \ldots, m_k$ is inherited.
2152 \end{itemize} 2164 \end{itemize}
2153 2165
2154 \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. 2166 \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.
2155 } 2167 }
2156 2168
2157 \rationale{ 2169 \rationale{
2158 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. 2170 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.
2159 2171
2160 (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. 2172 (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.
2161 } 2173 }
2162 2174
2175 % 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.
2176
2163 \section{Mixins} 2177 \section{Mixins}
2164 \label{mixins} 2178 \label{mixins}
2165 2179
2166 2180
2167 A mixin describes the difference between a class and its superclass. A mixin is always derived from an existing class declaration. 2181 A mixin describes the difference between a class and its superclass. A mixin is always derived from an existing class declaration.
2168 2182
2169 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}. 2183 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}.
2170 2184
2171 \rationale{ 2185 \rationale{
2172 These restrictions are temporary. We expect to remove them in later versions of Dart. 2186 These restrictions are temporary. We expect to remove them in later versions of Dart.
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
3746 {\bf assignmentOperator:}`=' ; 3760 {\bf assignmentOperator:}`=' ;
3747 compoundAssignmentOperator 3761 compoundAssignmentOperator
3748 . 3762 .
3749 \end{grammar} 3763 \end{grammar}
3750 3764
3751 Evaluation of an assignment $a$ of the form $v$ \code{=} $e$ proceeds as follows : 3765 Evaluation of an assignment $a$ of the form $v$ \code{=} $e$ proceeds as follows :
3752 3766
3753 3767
3754 If there is neither a local variable declaration with name $v$ nor a setter decl aration with name $v=$ in the lexical scope enclosing $a$, then: 3768 If there is neither a local variable declaration with name $v$ nor a setter decl aration with name $v=$ in the lexical scope enclosing $a$, then:
3755 \begin{itemize} 3769 \begin{itemize}
3756 \item If $a$ occurs inside a top level or static function (be it function, met hod, getter, or setter) or variable initializer, evaluation of $a$ causes $e$ t o be evaluated, after which a \code{NoSuchMethodError} is thrown. \item Otherwis e, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $e$}. 3770 \item If $a$ occurs inside a top level or static function (be it function, met hod, getter, or setter) or variable initializer, evaluation of $a$ causes $e$ t o be evaluated, after which a \code{NoSuchMethodError} is thrown.
3771 \item Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}. $v$ = $e$}.
3757 \end{itemize} 3772 \end{itemize}
3758 3773
3759 Otherwise, let $d$ be the innermost declaration whose name is $v$, if it exist s. 3774 Otherwise, let $d$ be the innermost declaration whose name is $v$, if it exist s.
3760 3775
3761 If $d$ is the declaration of a local variable, the expression $e$ is evaluated t o an object $o$. Then, the variable $v$ is bound to $o$. The value of the assign ment expression is $o$. 3776 If $d$ is the declaration of a local variable, the expression $e$ is evaluated t o an object $o$. Then, the variable $v$ is bound to $o$.
3777 % unless $v$ is \FINAL{}, in which case a \code{NoSuchMethodError} is thrown (ev en if there is a noSuchMethod).
3778 The value of the assignment expression is $o$.
3762 3779
3763 If $d$ is the declaration of a library variable, the expression $e$ is evaluated to an object $o$. Then the setter $v=$ is invoked with its formal parameter bou nd to $o$. The value of the assignment expression is $o$. 3780 If $d$ is the declaration of a library variable, the expression $e$ is evaluated to an object $o$. Then the setter $v=$ is invoked with its formal parameter bou nd to $o$. The value of the assignment expression is $o$.
3764 3781
3765 Otherwise, if $d$ is the declaration of a static variable in class $C$, then the assignment is equivalent to the assignment \code{$C.v$ = $e$}. 3782 Otherwise, if $d$ is the declaration of a static variable in class $C$, then the assignment is equivalent to the assignment \code{$C.v$ = $e$}.
3766 3783
3767 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}. 3784 Otherwise, the assignment is equivalent to the assignment \code{ \THIS{}.$v$ = $ e$}.
3768 3785
3769 In checked mode, it is a dynamic type error if $o$ is not \NULL{} and the interf ace of the class of $o$ is not a subtype of the actual type (\ref{actualTypeOfAD eclaration}) of $v$. 3786 In checked mode, it is a dynamic type error if $o$ is not \NULL{} and the interf ace of the class of $o$ is not a subtype of the actual type (\ref{actualTypeOfAD eclaration}) of $v$.
3770 3787
3771 It is a static type warning if the static type of $e$ may not be assigned to the static type of $v$. The static type of the expression $v$ \code{=} $e$ is the s tatic type of $e$. 3788 It is a static type warning if the static type of $e$ may not be assigned to the static type of $v$. The static type of the expression $v$ \code{=} $e$ is the s tatic type of $e$.
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after
5959 5976
5960 \begin{itemize} 5977 \begin{itemize}
5961 \item $[A_1, \ldots, A_n/U_1, \ldots, U_n]T$ if $d$ depends on type parameters $U_1, \ldots, U_n$, and $A_i$ is the value of $U_i, 1 \le i \le n$. 5978 \item $[A_1, \ldots, A_n/U_1, \ldots, U_n]T$ if $d$ depends on type parameters $U_1, \ldots, U_n$, and $A_i$ is the value of $U_i, 1 \le i \le n$.
5962 \item $T$ otherwise. 5979 \item $T$ otherwise.
5963 \end{itemize} 5980 \end{itemize}
5964 5981
5965 \subsubsection{Least Upper Bounds} 5982 \subsubsection{Least Upper Bounds}
5966 \label{leastUpperBounds} 5983 \label{leastUpperBounds}
5967 5984
5968 Given two interfaces $I$ and $J$, let $S_I$ be the set of superinterfaces of $I$ , let $S_J$ be the set of superinterfaces of $J$ and let $S = (I \cup S_I) \ca p (J \cup S_J)$. Furthermore, we define $S_n = \{T | T \in S \wedge depth(T) = n\}$ for any finite $n$ %, and $k=max(depth(T_1), \ldots, depth(T_m)), T_i \in S , i \in 1..m$, 5985 Given two interfaces $I$ and $J$, let $S_I$ be the set of superinterfaces of $I$ , let $S_J$ be the set of superinterfaces of $J$ and let $S = (I \cup S_I) \ca p (J \cup S_J)$. Furthermore, we define $S_n = \{T | T \in S \wedge depth(T) = n\}$ for any finite $n$ %, and $k=max(depth(T_1), \ldots, depth(T_m)), T_i \in S , i \in 1..m$,
5969 where $depth(T)$ is the number of steps in the longest inheritance path from $T$ to \code{Object}. Let $q$ be the largest number such that $S_q$ has cardinality one. The least upper bound of $I$ and $J$ is the sole element of $S_q$. 5986 where $depth(T)$ is the number of steps in the longest inheritance path from $T$ to \code{Object}. Let $q$ be the largest number such that $S_q$ has cardinality one. The least upper bound of $I$ and $J$ is the sole element of $S_q$.
Johnni Winther 2013/10/23 07:46:05 This part doesn't handle type arguments and theref
Johnni Winther 2013/10/24 11:34:49 The missing handling of generic types actually cau
5970 5987
5971 % void, dynamic, type variables need to be figured into this. 5988 The least upper bound of \DYNAMIC{} and any type $T$ is \DYNAMIC{}.
Johnni Winther 2013/10/23 07:46:05 Maybe this should be the opposite to follow the in
Johnni Winther 2013/10/24 14:05:01 I need to flip a bit in my head: any type _is_ mor
5989 The least upper bound of \VOID{} and any type $T \ne \DYNAMIC{}$ is \VOID{}.
Johnni Winther 2013/10/23 07:46:05 By the definition of << on function types we could
Johnni Winther 2013/10/24 14:05:01 Again. Noise. (Though a better warning in this exa
5990 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$.
Johnni Winther 2013/10/23 07:46:05 This rules follows the invariant!
Johnni Winther 2013/10/23 12:21:55 Looking closer at this, this is actually not well-
5972 5991
5973 5992 The least upper bound relation is symmetric and reflexive.
5993
5994 % Function types
Johnni Winther 2013/10/23 07:46:05 These rules follows the invariant!
5995
5996 The least upper bound of a function type and an interface type $T$ is the least upper bound of \cd{Function} and $T$.
5997 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:
5998 \begin{itemize}
5999 \item If $F= (T_1 \ldots T_r, [T_{r+1}, \ldots, T_n]) \longrightarrow T_0$ and $ G= (S_1 \ldots S_r, [S_{r+1}, \ldots, S_k]) \longrightarrow S_0$ where $k \le n$ then the least upper bound of $F$ and $G$ is $(L_1 \ldots L_r, [L_{r+1}, \ldots , L_k]) \longrightarrow L_0$ where $L_i$ is the least upper bound of $T_i$ and $ S_i, i \in 0..k$.
6000 \item If $F= (T_1 \ldots T_r, [T_{r+1}, \ldots, T_n]) \longrightarrow T_0$ and $ G= (S_1 \ldots S_r, \{ \ldots \}) \longrightarrow S_0$ then the least upper boun d of $F$ and $G$ is $(L_1 \ldots L_r) \longrightarrow L_0$ where $L_i$ is the le ast upper bound of $T_i$ and $S_i, i \in 0..r$.
6001 \item If $F= (T_1 \ldots T_r, \{T_{r+1}$ $p_{r+1}, \ldots, T_f$ $p_f\}) \longri ghtarrow T_0$ and $G= (S_1 \ldots S_r, \{ S_{r+1}$ $q_{r+1}, \ldots, S_g$ $q_g\ }) \longrightarrow S_0$ 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 t ypes of $x_j$ in $F$ and $G, j \in m..n$. Then
6002 the least upper bound of $F$ and $G$ is $(L_1 \ldots L_r, \{ X_m$ $x_m, \ldots, X_n$ $x_n\}) \longrightarrow L_0$ where $L_i$ is the least upper bound of $T_i$ and $S_i, i \in 0..r$
6003 \end{itemize}
6004
5974 6005
5975 \section{Reference} 6006 \section{Reference}
5976 \label{reference} 6007 \label{reference}
5977 6008
5978 \subsection{Lexical Rules} 6009 \subsection{Lexical Rules}
5979 \label{lexicalRules} 6010 \label{lexicalRules}
5980 6011
5981 Dart source text is represented as a sequence of Unicode code points. This sequ ence is first converted into a sequence of tokens according to the lexical rules given in this specification. At any point in the tokenization process, the lon gest possible token is recognized. 6012 Dart source text is represented as a sequence of Unicode code points. This sequ ence is first converted into a sequence of tokens according to the lexical rules given in this specification. At any point in the tokenization process, the lon gest possible token is recognized.
5982 6013
5983 \subsubsection{Reserved Words} 6014 \subsubsection{Reserved Words}
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
6092 \item The names of compile time constant variables never use lower case letters. If they consist of multiple words, those words are separated by underscores. Ex amples: PI, I\_AM\_A\_CONSTANT. 6123 \item The names of compile time constant variables never use lower case letters. If they consist of multiple words, those words are separated by underscores. Ex amples: PI, I\_AM\_A\_CONSTANT.
6093 \item The names of functions (including getters, setters, methods and local or l ibrary functions) and non-constant variables begin with a lowercase letter. If t he name consists of multiple words, each word (except the first) begins with an uppercase letter. No other uppercase letters are used. Examples: camlCase, dar t4TheWorld 6124 \item The names of functions (including getters, setters, methods and local or l ibrary functions) and non-constant variables begin with a lowercase letter. If t he name consists of multiple words, each word (except the first) begins with an uppercase letter. No other uppercase letters are used. Examples: camlCase, dar t4TheWorld
6094 \item The names of types (including classes and type aliases) begin with an uppe r case letter. If the name consists of multiple words, each word begins with an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D art4TheWorld. 6125 \item The names of types (including classes and type aliases) begin with an uppe r case letter. If the name consists of multiple words, each word begins with an uppercase letter. No other uppercase letters are used. Examples: CamlCase, D art4TheWorld.
6095 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E. 6126 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E.
6096 \item The names of libraries or library prefixes never use upper case letters. I f they consist of multiple words, those words are separated by underscores. Exam ple: my\_favorite\_library. 6127 \item The names of libraries or library prefixes never use upper case letters. I f they consist of multiple words, those words are separated by underscores. Exam ple: my\_favorite\_library.
6097 \end{itemize} 6128 \end{itemize}
6098 } 6129 }
6099 6130
6100 6131
6101 \end{document} 6132 \end{document}
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698