OLD | NEW |
---|---|
1 \documentclass{article} | 1 \documentclass{article} |
2 \usepackage{epsfig} | 2 \usepackage{epsfig} |
3 \usepackage{dart} | 3 \usepackage{dart} |
4 \usepackage{bnf} | 4 \usepackage{bnf} |
5 \usepackage{hyperref} | 5 \usepackage{hyperref} |
6 \newcommand{\code}[1]{{\sf #1}} | 6 \newcommand{\code}[1]{{\sf #1}} |
7 \title{Dart Programming Language Specification \\ | 7 \title{Dart Programming Language Specification \\ |
8 {\large Draft Version 0.71}} | 8 {\large Draft Version 0.8}} |
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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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} | 512 \subsubsection{Changes Since Version 0.7} |
513 | 513 |
514 | 514 |
515 \ref{variables}: Final variables no longer introduce setters. | 515 \ref{variables}: Final variables no longer introduce setters. |
516 | 516 |
517 \ref{superinterfaces}: Described \cd{@proxy} annotation's effects on typecheckin g. | |
518 | |
519 \ref{metadata}: Banned use of types as metadata. | |
520 | |
517 \ref{new}: Instantiating subclasses of malbounded types is a dynamic error. | 521 \ref{new}: Instantiating subclasses of malbounded types is a dynamic error. |
518 | 522 |
523 \ref{typeTest}, \ref{typeCast}, \ref{try}: Use of malformed type in casts, type tests and catch clauses is a dynamic error. | |
524 | |
525 \ref{scripts}: Corrected rules for running scripts. | |
526 | |
527 \ref{dynamicTypeSystem}: In checked mode, subtype tests against malbounded types are dynamic errors. | |
528 | |
519 \ref{leastUpperBounds}: Extended LUBs to all types. | 529 \ref{leastUpperBounds}: Extended LUBs to all types. |
520 | 530 |
521 | 531 |
522 | 532 |
523 \section{Notation} | 533 \section{Notation} |
524 \label{notation} | 534 \label{notation} |
525 | 535 |
526 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: | 536 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: |
527 \begin{itemize} | 537 \begin{itemize} |
528 \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.} | 538 \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.} |
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2073 | 2083 |
2074 It is a compile-time error if the \IMPLEMENTS{} clause of a class $C$ specifie s a type variable as a superinterface. It is a compile-time error if the \IMPL EMENTS{} clause of a class $C$ specifies a malformed type as a superinterface It is a compile-time error if the \IMPLEMENTS{} clause of a class $C$ specifies type \DYNAMIC{} as a superinterface. It is a compile-time error if the \IMPLEM ENTS{} clause of a class $C$ specifies a type $T$ as a superinterface more than once. | 2084 It is a compile-time error if the \IMPLEMENTS{} clause of a class $C$ specifie s a type variable as a superinterface. It is a compile-time error if the \IMPL EMENTS{} clause of a class $C$ specifies a malformed type as a superinterface It is a compile-time error if the \IMPLEMENTS{} clause of a class $C$ specifies type \DYNAMIC{} as a superinterface. It is a compile-time error if the \IMPLEM ENTS{} clause of a class $C$ specifies a type $T$ as a superinterface more than once. |
2075 It is a compile-time error if the superclass of a class $C$ is specified as a su perinterface of $C$. | 2085 It is a compile-time error if the superclass of a class $C$ is specified as a su perinterface of $C$. |
2076 | 2086 |
2077 \rationale{ | 2087 \rationale{ |
2078 One might argue that it is harmless to repeat a type in the superinterface list, so why make it an error? The issue is not so much that the situation described in program source is erroneous, but that it is pointless. As such, it is an indi cation that the programmer may very well have meant to say something else - and that is a mistake that should be called to her or his attention. Nevertheless, we could simply issue a warning; and perhaps we should and will. That said, prob lems like these are local and easily corrected on the spot, so we feel justified in taking a harder line. | 2088 One might argue that it is harmless to repeat a type in the superinterface list, so why make it an error? The issue is not so much that the situation described in program source is erroneous, but that it is pointless. As such, it is an indi cation that the programmer may very well have meant to say something else - and that is a mistake that should be called to her or his attention. Nevertheless, we could simply issue a warning; and perhaps we should and will. That said, prob lems like these are local and easily corrected on the spot, so we feel justified in taking a harder line. |
2079 } | 2089 } |
2080 | 2090 |
2081 It is a compile-time error if the interface of a class $C$ is a superinterface o f itself. | 2091 It is a compile-time error if the interface of a class $C$ is a superinterface o f itself. |
2082 | 2092 |
2083 Let $C$ be a concrete class that does not declare its own \code{noSuchMethod()} method. | 2093 Let $C$ be a concrete class that does not declare its own \code{noSuchMethod()} method and is not annotated with a metadata declaration of the form \cd{@proxy}, where \cd{proxy} is declared in \cd{dart:core}. |
2084 It is a static warning if the implicit interface of $C$ includes an instance me mber $m$ of type $F$ and $C$ does not declare or inherit a corresponding instanc e member $m$ of type $F'$ such that $F' <: F$. | 2094 It is a static warning if the implicit interface of $C$ includes an instance me mber $m$ of type $F$ and $C$ does not declare or inherit a corresponding instanc e member $m$ of type $F'$ such that $F' <: F$. |
2085 | 2095 |
2086 \commentary{A class does not inherit members from its superinterfaces. However, its implicit interface does. | 2096 \commentary{A class does not inherit members from its superinterfaces. However, its implicit interface does. |
2087 } | 2097 } |
2088 | 2098 |
2089 | 2099 |
2090 \rationale { | 2100 \rationale { |
2091 We choose to issue these warnings only for concrete classes; an abstract class m ight legitimately be designed with the expectation that concrete subclasses will implement part of the interface. | 2101 We choose to issue these warnings only for concrete classes; an abstract class m ight legitimately be designed with the expectation that concrete subclasses will implement part of the interface. |
2092 We also disable these warnings if a \code{noSuchMethod()} declaration is present . In such cases, the supported interface is going to be implemented via \code{no SuchMethod()} and no actual declarations of the implemented interface's members are needed. This allows proxy classes for specific types to be implemented witho ut provoking type warnings. | 2102 We also disable these warnings if a \code{noSuchMethod()} declaration is present . In such cases, the supported interface is going to be implemented via \code{no SuchMethod()} and no actual declarations of the implemented interface's members are needed. This allows proxy classes for specific types to be implemented witho ut provoking type warnings. |
2103 | |
2104 In addition, it may be useful to suppress these warnings if \code{noSuchMethod} is inherited, However, this may suppress meaningful warnings and so we choose no t to do so by default. Instead, a special annotation is defined in \cd{dart:core } for this purpose. | |
2093 } | 2105 } |
2094 | 2106 |
2095 It is a static warning if the implicit interface of a class $C$ includes an ins tance member $m$ of type $F$ and $C$ declares or inherits a corresponding instan ce member $m$ of type $F'$ if $F'$ is not a subtype of $F$. | 2107 It is a static warning if the implicit interface of a class $C$ includes an ins tance member $m$ of type $F$ and $C$ declares or inherits a corresponding instan ce member $m$ of type $F'$ if $F'$ is not a subtype of $F$. |
2096 | 2108 |
2097 \rationale{ | 2109 \rationale{ |
2098 However, if a class does explicitly declare a member that conflicts with its sup erinterface, this always yields a static warning. | 2110 However, if a class does explicitly declare a member that conflicts with its sup erinterface, this always yields a static warning. |
2099 | 2111 |
2100 } | 2112 } |
2101 %It is a static warning if an imported superinterface of a class $C$ declares pr ivate members. | 2113 %It is a static warning if an imported superinterface of a class $C$ declares pr ivate members. |
2102 | 2114 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2247 | 2259 |
2248 A mixin application of the form \code{$S$ \WITH{} $M_1, \ldots, M_k$;} defines a class $C$ whose superclass is the application of the mixin composition (\ref {mixinComposition}) $M_{k-1} * \ldots * M_1$ to $S$. | 2260 A mixin application of the form \code{$S$ \WITH{} $M_1, \ldots, M_k$;} defines a class $C$ whose superclass is the application of the mixin composition (\ref {mixinComposition}) $M_{k-1} * \ldots * M_1$ to $S$. |
2249 | 2261 |
2250 In both cases above, $C$ declares the same instance members as $M$ (respectively , $M_k$). If any of the instance fields of $M$ (respectively, $M_k$) have initia lizers, they are executed in the scope of $M$ (respectively, $M_k$) to initializ e the corresponding fields of $C$. | 2262 In both cases above, $C$ declares the same instance members as $M$ (respectively , $M_k$). If any of the instance fields of $M$ (respectively, $M_k$) have initia lizers, they are executed in the scope of $M$ (respectively, $M_k$) to initializ e the corresponding fields of $C$. |
2251 | 2263 |
2252 For each generative constructor named $q_i(T_{i1}$ $ a_{i1}, \ldots , T_{ik_i}$ $ a_{ik_i}), i \in 1..n$ of $S$, $C$ has an implicitly declared constructor name d | 2264 For each generative constructor named $q_i(T_{i1}$ $ a_{i1}, \ldots , T_{ik_i}$ $ a_{ik_i}), i \in 1..n$ of $S$, $C$ has an implicitly declared constructor name d |
2253 $q'_i = [C/S]q_i$ of the form | 2265 $q'_i = [C/S]q_i$ of the form |
2254 | 2266 |
2255 $q'_i(a_{i1}, \ldots , a_{ik_i}):\SUPER(a_{i1}, \ldots , a_{ik_i});$. | 2267 $q'_i(a_{i1}, \ldots , a_{ik_i}):\SUPER(a_{i1}, \ldots , a_{ik_i});$. |
2256 | 2268 |
2257 % The types must be given in the copied constructor. It was tempting to elide th em; after all, checked mode will catch things in the | |
2258 % super call - but this may be a problem for tools. | |
2259 % We interpret this instead as S includes the generic parameters, so the signat ure has already substituted them. | |
2260 % Default values may not be replicable for optional params due to scoping/privac y. | |
2261 % How to describe and implement | |
2262 | |
2263 %The class $C$ has an implicitly declared nullary generative constructor with no initializer list and no body. | |
2264 | |
2265 If the mixin application declares support for interfaces, the resulting class im plements those interfaces. | 2269 If the mixin application declares support for interfaces, the resulting class im plements those interfaces. |
2266 | 2270 |
2267 It is a compile-time error if $S$ is a malformed type. It is a compile-time erro r if $M$ (respectively, any of $M_1, \ldots, M_k$) is a malformed type. It is a compile time error if a well formed mixin cannot be derived from $M$ (respective ly, from each of $M_1, \ldots, M_k$). | 2271 It is a compile-time error if $S$ is a malformed type. It is a compile-time erro r if $M$ (respectively, any of $M_1, \ldots, M_k$) is a malformed type. It is a compile time error if a well formed mixin cannot be derived from $M$ (respective ly, from each of $M_1, \ldots, M_k$). |
2268 | 2272 |
2269 Let $K$ be a class declaration with the same constructors, superclass and inter faces as $C$, and the instance members declared by $M$ (respectively $M_1, \ldo ts, M_k$). It is a static warning if the declaration of $K$ would cause a static warning. It is a compile-time error if the declaration of $K$ would cause a co mpile-time error. | 2273 Let $K$ be a class declaration with the same constructors, superclass and inter faces as $C$, and the instance members declared by $M$ (respectively $M_1, \ldo ts, M_k$). It is a static warning if the declaration of $K$ would cause a static warning. It is a compile-time error if the declaration of $K$ would cause a co mpile-time error. |
2270 | 2274 |
2271 \commentary{ | 2275 \commentary{ |
2272 If, for example, $M$ declares an instance member $im$ whose type is at odds with the type of a member of the same name in $S$, this will result in a static warn ing just as if we had defined $K$ by means of an ordinary class declaration exte nding $S$, with a body that included $im$. | 2276 If, for example, $M$ declares an instance member $im$ whose type is at odds with the type of a member of the same name in $S$, this will result in a static warn ing just as if we had defined $K$ by means of an ordinary class declaration exte nding $S$, with a body that included $im$. |
2273 | 2277 |
2274 %Another implication of this definition is that one cannot apply a mixin to a su perclass that does not provide a nullary constructor. | |
2275 } | 2278 } |
2276 | 2279 |
2277 The effect of a class definition of the form \code{\CLASS{} $C$ = $M$; } or the form | 2280 The effect of a class definition of the form \code{\CLASS{} $C$ = $M$; } or the form |
2278 \code{\CLASS{} $C<T_1, \ldots, T_n>$ = $M$; } in library $L$ is to introduce t he name $C$ into the scope of $L$, bound to the class (\ref{classes}) defined by the mixin application $M$. The name of the class is also set to $C$. Iff the c lass is prefixed by the built-in identifier \ABSTRACT{}, the class being defined is an abstract class. | 2281 \code{\CLASS{} $C<T_1, \ldots, T_n>$ = $M$; } in library $L$ is to introduce t he name $C$ into the scope of $L$, bound to the class (\ref{classes}) defined by the mixin application $M$. The name of the class is also set to $C$. Iff the c lass is prefixed by the built-in identifier \ABSTRACT{}, the class being defined is an abstract class. |
2279 | 2282 |
2280 | 2283 |
2281 \subsection{Mixin Composition} | 2284 \subsection{Mixin Composition} |
2282 \label{mixinComposition} | 2285 \label{mixinComposition} |
2283 | 2286 |
2284 \rationale{ | 2287 \rationale{ |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2402 | 2405 |
2403 \begin{grammar} | 2406 \begin{grammar} |
2404 {\bf metadata:} | 2407 {\bf metadata:} |
2405 (`@' qualified ({\escapegrammar `.'} identifier)? (arguments)?)* | 2408 (`@' qualified ({\escapegrammar `.'} identifier)? (arguments)?)* |
2406 . | 2409 . |
2407 \end{grammar} | 2410 \end{grammar} |
2408 | 2411 |
2409 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: | 2412 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: |
2410 \begin{itemize} | 2413 \begin{itemize} |
2411 \item A reference to a compile-time constant variable. | 2414 \item A reference to a compile-time constant variable. |
2412 \item The name of a class. | |
2413 \item A call to a constant constructor. | 2415 \item A call to a constant constructor. |
2414 \end{itemize} | 2416 \end{itemize} |
2415 | 2417 |
2416 Metadata is associated with the abstract syntax tree of the program construct $p $ that immediately follows the metadata, assuming $p$ is not itself metadata or a comment. Metadata can be retrieved at runtime via a reflective call, provided the annotated program construct $p$ is accessible via reflection. | 2418 Metadata is associated with the abstract syntax tree of the program construct $p $ that immediately follows the metadata, assuming $p$ is not itself metadata or a comment. Metadata can be retrieved at runtime via a reflective call, provided the annotated program construct $p$ is accessible via reflection. |
2417 | 2419 |
2418 \commentary{ | 2420 \commentary{ |
2419 Obviously, metadata can also be retrieved statically by parsing the program and evaluating the constants via a suitable interpreter. In fact many if not most us es of metadata are entirely static. | 2421 Obviously, metadata can also be retrieved statically by parsing the program and evaluating the constants via a suitable interpreter. In fact many if not most us es of metadata are entirely static. |
2420 } | 2422 } |
2421 | 2423 |
2422 \rationale{ | 2424 \rationale{ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2516 A {\em constant expression} is an expression whose value can never change, and t hat can be evaluated entirely at compile time. | 2518 A {\em constant expression} is an expression whose value can never change, and t hat can be evaluated entirely at compile time. |
2517 | 2519 |
2518 A constant expression is one of the following: | 2520 A constant expression is one of the following: |
2519 \begin{itemize} | 2521 \begin{itemize} |
2520 \item A literal number (\ref{numbers}). | 2522 \item A literal number (\ref{numbers}). |
2521 \item A literal boolean (\ref{booleans}). | 2523 \item A literal boolean (\ref{booleans}). |
2522 \item A literal string (\ref{strings}) where any interpolated expression (\ref{ stringInterpolation}) is a compile-time constant that evaluates to a numeric, st ring or boolean value or to \NULL{}. | 2524 \item A literal string (\ref{strings}) where any interpolated expression (\ref{ stringInterpolation}) is a compile-time constant that evaluates to a numeric, st ring or boolean value or to \NULL{}. |
2523 \rationale{It would be tempting to allow string interpolation where the interpol ated value is any compile-time constant. However, this would require running th e \code{toString()} method for constant objects, which could contain arbitrary c ode.} | 2525 \rationale{It would be tempting to allow string interpolation where the interpol ated value is any compile-time constant. However, this would require running th e \code{toString()} method for constant objects, which could contain arbitrary c ode.} |
2524 \item A literal symbol (\ref{symbols}). | 2526 \item A literal symbol (\ref{symbols}). |
2525 \item \NULL{} (\ref{null}). | 2527 \item \NULL{} (\ref{null}). |
2526 \item A qualified reference to a static constant variable (\ref{variables}). \co mmentary {For example, If class C declares a constant static variable v, C.v is a constant. The same is true if C is accessed via a prefix p; p.C.v is a constan t. | 2528 \item A qualified reference to a static constant variable (\ref{variables}). |
2529 \commentary {For example, If class C declares a constant static variable v, C.v is a constant. The same is true if C is accessed via a prefix p; p.C.v is a cons tant. | |
2527 } | 2530 } |
2528 \item An identifier expression that denotes a constant variable, class or a type alias. | 2531 \item An identifier expression that denotes a constant variable. %CHANGE in goog ledoc |
2532 \item A simple or qualified identifier denoting a class or a type alias. | |
2533 \commentary {For example, if C is a class or typedef C is a constant, and if C i s imported with a prefix p, p.C is a constant. | |
2534 } | |
2529 \item A constant constructor invocation (\ref{const}). | 2535 \item A constant constructor invocation (\ref{const}). |
2530 \item A constant list literal (\ref{lists}). | 2536 \item A constant list literal (\ref{lists}). |
2531 \item A constant map literal (\ref{maps}). | 2537 \item A constant map literal (\ref{maps}). |
2532 \item A simple or qualified identifier denoting a top-level function (\ref{funct ions}) or a static method (\ref{staticMethods}). | 2538 \item A simple or qualified identifier denoting a top-level function (\ref{funct ions}) or a static method (\ref{staticMethods}). |
2533 \item A parenthesized expression \code{($e$)} where $e$ is a constant expression . | 2539 \item A parenthesized expression \code{($e$)} where $e$ is a constant expression . |
2534 \item An expression of the form \code{identical($e_1$, $e_2$)} where $e_1$ and $ e_2$ are constant expressions and \code{identical()} is statically bound to the predefined dart function \code{identical()} discussed above (\ref{objectIdent ity}). | 2540 \item An expression of the form \code{identical($e_1$, $e_2$)} where $e_1$ and $ e_2$ are constant expressions and \code{identical()} is statically bound to the predefined dart function \code{identical()} discussed above (\ref{objectIdent ity}). |
2535 \item An expression of one of the forms \code{$e_1$ == $e_2$} or \code{$e_1$ ! = $e_2$} where $e_1$ and $e_2$ are constant expressions that evaluate to a numer ic, string or boolean value or to \NULL{}. | 2541 \item An expression of one of the forms \code{$e_1$ == $e_2$} or \code{$e_1$ ! = $e_2$} where $e_1$ and $e_2$ are constant expressions that evaluate to a numer ic, string or boolean value or to \NULL{}. |
2536 \item An expression of one of the forms \code{!$e$}, \code{$e_1$ \&\& $e_2$} or \code{$e_1 || e_2$}, where $e$, $e_1$ and $e_2$ are constant expressions that e valuate to a boolean value. | 2542 \item An expression of one of the forms \code{!$e$}, \code{$e_1$ \&\& $e_2$} or \code{$e_1 || e_2$}, where $e$, $e_1$ and $e_2$ are constant expressions that e valuate to a boolean value. |
2537 \item An expression of one of the forms \~{}$e$, $e_1$ \^{} $e_2$, \code{$e_1$ \ & $e_2$}, $e_1 | e_2$, $e_1 >> e_2$ or $e_1 << e_2$, where $e$, $e_1$ and $e_2 $ are constant expressions that evaluate to an integer value or to \NULL{}. | 2543 \item An expression of one of the forms \~{}$e$, $e_1$ \^{} $e_2$, \code{$e_1$ \ & $e_2$}, $e_1 | e_2$, $e_1 >> e_2$ or $e_1 << e_2$, where $e$, $e_1$ and $e_2 $ are constant expressions that evaluate to an integer value or to \NULL{}. |
2538 \item An expression of one of the forms \code{$-e$}, \code{$e_1 + e_2$}, \code{ $e_1$ - $e_2$}, \code{$e_1$ * $e_2$}, \code{$e_1$ / $e_2$,} \code{$e_1$ \~{}/ $e _2$}, \code{$e_1 > e_2$}, \code{$e_1 < e_2$}, \code{$e_1$ $>$= $e_2$}, \cod e{$e_1$ $<$= $e_2$} or \code{$e_1$ \% $e_2$}, where $e$, $e_1$ and $e_2$ are co nstant expressions that evaluate to a numeric value or to \NULL{}. | 2544 \item An expression of one of the forms \code{$-e$}, \code{$e_1 + e_2$}, \code{ $e_1$ - $e_2$}, \code{$e_1$ * $e_2$}, \code{$e_1$ / $e_2$,} \code{$e_1$ \~{}/ $e _2$}, \code{$e_1 > e_2$}, \code{$e_1 < e_2$}, \code{$e_1$ $>$= $e_2$}, \cod e{$e_1$ $<$= $e_2$} or \code{$e_1$ \% $e_2$}, where $e$, $e_1$ and $e_2$ are co nstant expressions that evaluate to a numeric value or to \NULL{}. |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2950 The value of a constant list literal \CONST{} $<E>[e_1\ldots e_n]$ is an object $a$ whose class implements the built-in class $List<E>$. The $i$th element of $ a$ is $v_{i+1}$, where $v_i$ is the value of the compile-time expression $e_i$. The value of a constant list literal \CONST{} $[e_1 \ldots e_n]$ is defined as the value of the constant list literal \CONST{}$ < \DYNAMIC{}>[e_1\ldots e_n]$. | 2956 The value of a constant list literal \CONST{} $<E>[e_1\ldots e_n]$ is an object $a$ whose class implements the built-in class $List<E>$. The $i$th element of $ a$ is $v_{i+1}$, where $v_i$ is the value of the compile-time expression $e_i$. The value of a constant list literal \CONST{} $[e_1 \ldots e_n]$ is defined as the value of the constant list literal \CONST{}$ < \DYNAMIC{}>[e_1\ldots e_n]$. |
2951 | 2957 |
2952 Let $list_1 =$ \CONST{} $<V>[e_{11} \ldots e_{1n}]$ and $list_2 =$ \CONST{} $<U >[e_{21} \ldots e_{2n}]$ be two constant list literals and let the elements of $list_1$ and $list_2$ evaluate to $o_{11} \ldots o_{1n}$ and $o_{21} \ldots o_ {2n}$ respectively. Iff \code{identical($o_{1i}$, $o_{2i}$)} for $i \in 1.. n$ a nd $V = U$ then \code{identical($list_1$, $list_2$)}. | 2958 Let $list_1 =$ \CONST{} $<V>[e_{11} \ldots e_{1n}]$ and $list_2 =$ \CONST{} $<U >[e_{21} \ldots e_{2n}]$ be two constant list literals and let the elements of $list_1$ and $list_2$ evaluate to $o_{11} \ldots o_{1n}$ and $o_{21} \ldots o_ {2n}$ respectively. Iff \code{identical($o_{1i}$, $o_{2i}$)} for $i \in 1.. n$ a nd $V = U$ then \code{identical($list_1$, $list_2$)}. |
2953 | 2959 |
2954 \commentary{In other words, constant list literals are canonicalized.} | 2960 \commentary{In other words, constant list literals are canonicalized.} |
2955 | 2961 |
2956 A run-time list literal $<E>[e_1 \ldots e_n]$ is evaluated as follows: | 2962 A run-time list literal $<E>[e_1 \ldots e_n]$ is evaluated as follows: |
2957 \begin{itemize} | 2963 \begin{itemize} |
2958 \item | 2964 \item |
2959 First, the expressions $e_1 \ldots e_n$ are evaluated in order they appear in th e program, yielding objects $o_1 \ldots o_n$. | 2965 First, the expressions $e_1 \ldots e_n$ are evaluated in order they appear in th e program, yielding objects $o_1 \ldots o_n$. |
2960 \item | 2966 \item A fresh instance (\ref{generativeConstructors}) $a$, of size $n$, whose class implements the built-in class $List<E>$ is allocated. |
2961 A fresh instance (\ref{generativeConstructors}) $a$, of size $n$, whose class implements the built-in class $List<E>$ is allocated. | |
2962 \item | 2967 \item |
2963 | 2968 |
2964 The operator \code{[]=} is invoked on $a$ with first argument $i$ and second a rgument | 2969 The operator \code{[]=} is invoked on $a$ with first argument $i$ and second a rgument |
2965 %The $i$th element of $a$ is set to | 2970 %The $i$th element of $a$ is set to |
2966 $o_{i+1}, 0 \le i < n$. | 2971 $o_{i+1}, 0 \le i < n$. |
2967 \item | 2972 \item |
2968 The result of the evaluation is $a$. | 2973 The result of the evaluation is $a$. |
2969 \end{itemize} | 2974 \end{itemize} |
2970 | 2975 |
2971 | 2976 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3016 The value of a constant map literal \CONST{}$ <K, V>\{k_1:e_1\ldots k_n :e_n\}$ is an object $m$ whose class implements the built-in class $Map<K, V>$. The ent ries of $m$ are $u_i:v_i, i \in 1 .. n$, where $u_i$ is the value of the compile -time expression $k_i$ and $v_i$ is the value of the compile-time expression $e_ i$. The value of a constant map literal \CONST{} $\{k_1:e_1\ldots k_n :e_n\}$ is defined as the value of a constant map literal \CONST{} $<\DYNAMIC{}, \DYNAMI C{}>\{k_1:e_1\ldots k_n :e_n\}$. | 3021 The value of a constant map literal \CONST{}$ <K, V>\{k_1:e_1\ldots k_n :e_n\}$ is an object $m$ whose class implements the built-in class $Map<K, V>$. The ent ries of $m$ are $u_i:v_i, i \in 1 .. n$, where $u_i$ is the value of the compile -time expression $k_i$ and $v_i$ is the value of the compile-time expression $e_ i$. The value of a constant map literal \CONST{} $\{k_1:e_1\ldots k_n :e_n\}$ is defined as the value of a constant map literal \CONST{} $<\DYNAMIC{}, \DYNAMI C{}>\{k_1:e_1\ldots k_n :e_n\}$. |
3017 | 3022 |
3018 Let $map_1 =$ \CONST{}$ <K, V>\{k_{11}:e_{11} \ldots k_{1n} :e_{1n}\}$ and $map _2 =$ \CONST{}$ <J, U>\{k_{21}:e_{21} \ldots k_{2n} :e_{2n}\}$ be two constant map literals. Let the keys of $map_1$ and $map_2$ evaluate to $s_{11} \ldots s _{1n}$ and $s_{21} \ldots s_{2n}$ respectively, and let the elements of $map _1$ and $map_2$ evaluate to $o_{11} \ldots o_{1n}$ and $o_{21} \ldots o_{2n}$ respectively. Iff \code{identical($o_{1i}$, $o_{2i}$)} and \code{identical($s_{ 1i}$, $s_{2i}$)} for $i \in 1.. n$, and $K = J, V = U$ then \code{identical($map _1$, $map_2$)}. | 3023 Let $map_1 =$ \CONST{}$ <K, V>\{k_{11}:e_{11} \ldots k_{1n} :e_{1n}\}$ and $map _2 =$ \CONST{}$ <J, U>\{k_{21}:e_{21} \ldots k_{2n} :e_{2n}\}$ be two constant map literals. Let the keys of $map_1$ and $map_2$ evaluate to $s_{11} \ldots s _{1n}$ and $s_{21} \ldots s_{2n}$ respectively, and let the elements of $map _1$ and $map_2$ evaluate to $o_{11} \ldots o_{1n}$ and $o_{21} \ldots o_{2n}$ respectively. Iff \code{identical($o_{1i}$, $o_{2i}$)} and \code{identical($s_{ 1i}$, $s_{2i}$)} for $i \in 1.. n$, and $K = J, V = U$ then \code{identical($map _1$, $map_2$)}. |
3019 | 3024 |
3020 \commentary{In other words, constant map literals are canonicalized.} | 3025 \commentary{In other words, constant map literals are canonicalized.} |
3021 | 3026 |
3022 A runtime map literal $<K, V>\{k_1:e_1\ldots k_n :e_n\}$ is evaluated as follow s: | 3027 A runtime map literal $<K, V>\{k_1:e_1\ldots k_n :e_n\}$ is evaluated as follow s: |
3023 \begin{itemize} | 3028 \begin{itemize} |
3024 \item | 3029 \item |
3025 First, the expression $k_i$ is evaluated yielding object $u_i$, the $e_i$ is vau lted yielding object $o_i$, for $i \in 1..n$ in left to right order, yielding ob jects $u_1, o_1\ldots u_n, o_n$. | 3030 First, the expression $k_i$ is evaluated yielding object $u_i$, the $e_i$ is vau lted yielding object $o_i$, for $i \in 1..n$ in left to right order, yielding ob jects $u_1, o_1\ldots u_n, o_n$. |
3026 \item | 3031 \item A fresh instance (\ref{generativeConstructors}) $m$ whose class implement s the built-in class $Map<K, V>$ is allocated. |
3027 A fresh instance (\ref{generativeConstructors}) $m$ whose class implements the b uilt-in class $Map<K, V>$ is allocated. | |
3028 \item | 3032 \item |
3029 The operator \code{[]=} is invoked on $m$ with first argument $u_i$ and second argument $o_i, i \in 1.. n$. | 3033 The operator \code{[]=} is invoked on $m$ with first argument $u_i$ and second argument $o_i, i \in 1.. n$. |
3030 \item | 3034 \item |
3031 The result of the evaluation is $m$. | 3035 The result of the evaluation is $m$. |
3032 \end{itemize} | 3036 \end{itemize} |
3033 | 3037 |
3034 | 3038 |
3035 A runtime map literal $\{k_1:e_1\ldots k_n :e_n\}$ is evaluated as $<\DYNAMIC{ }, \DYNAMIC{}>\{k_1:e_1\ldots k_n :e_n\}$. | 3039 A runtime map literal $\{k_1:e_1\ldots k_n :e_n\}$ is evaluated as $<\DYNAMIC{ }, \DYNAMIC{}>\{k_1:e_1\ldots k_n :e_n\}$. |
3036 | 3040 |
3037 Iff all the keys in a map literal are compile-time constants, it is a static war ning if the values of any two keys in a map literal are equal. | 3041 Iff all the keys in a map literal are compile-time constants, it is a static war ning if the values of any two keys in a map literal are equal. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3203 | 3207 |
3204 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated. | 3208 First, the argument list $(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots , x_{n+k} : a_{n+k})$ is evaluated. |
3205 | 3209 |
3206 Then, if $q$ is a non-factory constructor of an abstract class then an \code{Abs tractClassInstantiationError} is thrown. | 3210 Then, if $q$ is a non-factory constructor of an abstract class then an \code{Abs tractClassInstantiationError} is thrown. |
3207 | 3211 |
3208 If $T$ is malformed or if $T$ is a type variable a dynamic error occurs. In che cked mode, if $T$ or any of its superclasses is malbounded a dynamic error occur s. | 3212 If $T$ is malformed or if $T$ is a type variable a dynamic error occurs. In che cked mode, if $T$ or any of its superclasses is malbounded a dynamic error occur s. |
3209 Otherwise, if $q$ is not defined or not accessible, a \code{NoSuchMethodError} is thrown. If $q$ has less than $n$ positional parameters or more than $n$ req uired parameters, or if $q$ lacks any of the keyword parameters $\{ x_{n+1}, \ld ots, x_{n+k}\}$ a \code{NoSuchMethodError} is thrown. | 3213 Otherwise, if $q$ is not defined or not accessible, a \code{NoSuchMethodError} is thrown. If $q$ has less than $n$ positional parameters or more than $n$ req uired parameters, or if $q$ lacks any of the keyword parameters $\{ x_{n+1}, \ld ots, x_{n+k}\}$ a \code{NoSuchMethodError} is thrown. |
3210 | 3214 |
3211 Otherwise, if $q$ is a generative constructor (\ref{generativeConstructors}), th en: | 3215 Otherwise, if $q$ is a generative constructor (\ref{generativeConstructors}), th en: |
3212 | 3216 |
3213 %Let $T_i$ be the type parameters of $R$ (if any) and let $B_i$ be the bound of $T_i, 1 \le i \le l$. | |
3214 %In checked mode, it is a dynamic type error if $V_i$ is not a subtype of $[V_ 1, \ldots, V_l/T_1, \ldots, T_l]B_i, i \in 1.. l$. | |
3215 | |
3216 \commentary{Note that it this point we are assured that the number of actual typ e arguments match the number of formal type parameters.} | 3217 \commentary{Note that it this point we are assured that the number of actual typ e arguments match the number of formal type parameters.} |
3217 | 3218 |
3218 A fresh instance (\ref{generativeConstructors}), $i$, of class $R$ is allocated . For each instance variable $f$ of $i$, if the variable declaration of $f$ has an initializer expression $e_f$, then $e_f$ is evaluated to an object $o_f$ and $f$ is bound to $o_f$. Otherwise $f$ is bound to \NULL{}. | 3219 A fresh instance (\ref{generativeConstructors}), $i$, of class $R$ is allocated . For each instance variable $f$ of $i$, if the variable declaration of $f$ has an initializer expression $e_f$, then $e_f$ is evaluated to an object $o_f$ and $f$ is bound to $o_f$. Otherwise $f$ is bound to \NULL{}. |
3219 | 3220 |
3220 \commentary{ | 3221 \commentary{ |
3221 Observe that \THIS{} is not in scope in $e_f$. Hence, the initialization cannot depend on other properties of the object being instantiated. | 3222 Observe that \THIS{} is not in scope in $e_f$. Hence, the initialization cannot depend on other properties of the object being instantiated. |
3222 } | 3223 } |
3223 | 3224 |
3224 Next, $q$ is executed with \THIS{} bound to $i$, the type parameters (if any) of $R$ bound to the actual type arguments $V_1, \ldots, V_l$ and the formal par ameter bindings that resulted from the evaluation of the argument list. The resu lt of the evaluation of $e$ is $i$. | 3225 Next, $q$ is executed with \THIS{} bound to $i$, the type parameters (if any) of $R$ bound to the actual type arguments $V_1, \ldots, V_l$ and the formal par ameter bindings that resulted from the evaluation of the argument list. The resu lt of the evaluation of $e$ is $i$. |
3225 | 3226 |
3226 Otherwise, $q$ is a factory constructor (\ref{factories}). Then: | 3227 Otherwise, $q$ is a factory constructor (\ref{factories}). Then: |
3227 | 3228 |
3228 %Let $T_i$ be the type parameters of $R$ (if any) and let $B_i$ be the bound of $T_i, 1 \le i \le l$. | |
3229 %In checked mode, it is a dynamic type error if $V_i$ is not a subtype of $[V_ 1, \ldots, V_l/T_1, \ldots, T_l]B_i, i \in 1.. l$. | |
3230 | |
3231 If $q$ is a redirecting factory constructor of the form $T(p_1, \ldots, p_{n+k}) = c;$ or of the form $T.id(p_1, \ldots, p_{n+k}) = c;$ then the result of the evaluation of $e$ is equivalent to evaluating the expression $[V_1, \ldots, V_m /T_1, \ldots, T_m]($\code{\NEW{} $c(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k}))$}. | 3229 If $q$ is a redirecting factory constructor of the form $T(p_1, \ldots, p_{n+k}) = c;$ or of the form $T.id(p_1, \ldots, p_{n+k}) = c;$ then the result of the evaluation of $e$ is equivalent to evaluating the expression $[V_1, \ldots, V_m /T_1, \ldots, T_m]($\code{\NEW{} $c(a_1, \ldots, a_n, x_{n+1}: a_{n+1}, \ldots, x_{n+k}: a_{n+k}))$}. |
3232 | 3230 |
3233 Otherwise, the body of $q$ is executed with respect to the bindings that resulte d from the evaluation of the argument list and the type parameters (if any) of $ q$ bound to the actual type arguments $V_1, \ldots, V_l$ resulting in an object $i$. The result of the evaluation of $e$ is $i$. | 3231 Otherwise, the body of $q$ is executed with respect to the bindings that resulte d from the evaluation of the argument list and the type parameters (if any) of $ q$ bound to the actual type arguments $V_1, \ldots, V_l$ resulting in an object $i$. The result of the evaluation of $e$ is $i$. |
3234 | 3232 |
3235 It is a static warning if $q$ is a constructor of an abstract class and $q$ is n ot a factory constructor. | 3233 It is a static warning if $q$ is a constructor of an abstract class and $q$ is n ot a factory constructor. |
3236 | 3234 |
3237 \commentary{The above gives precise meaning to the idea that instantiating an ab stract class leads to a warning. | 3235 \commentary{The above gives precise meaning to the idea that instantiating an ab stract class leads to a warning. |
3238 A similar clause applies to constant object creation in the next section. | 3236 A similar clause applies to constant object creation in the next section. |
3239 } | 3237 } |
3240 | 3238 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3445 | 3443 |
3446 {\bf argumentList:}namedArgument (`,' namedArgument)*; | 3444 {\bf argumentList:}namedArgument (`,' namedArgument)*; |
3447 % expressionList ',' spreadArgument; | 3445 % expressionList ',' spreadArgument; |
3448 expressionList (`,' namedArgument)* | 3446 expressionList (`,' namedArgument)* |
3449 % spreadArgument | 3447 % spreadArgument |
3450 . | 3448 . |
3451 | 3449 |
3452 {\bf namedArgument:} | 3450 {\bf namedArgument:} |
3453 label expression % could be top level expression? | 3451 label expression % could be top level expression? |
3454 . | 3452 . |
3455 | |
3456 %spreadArgument: | |
3457 % '...' expression | |
3458 % . | |
3459 \end{grammar} | 3453 \end{grammar} |
3460 | 3454 |
3461 Evaluation of an actual argument list of the form $(a_1, \ldots, a_m, q_1: a_{m+ 1}, \ldots, q_l: a_{m+l})$ proceeds as follows: | 3455 Evaluation of an actual argument list of the form $(a_1, \ldots, a_m, q_1: a_{m+ 1}, \ldots, q_l: a_{m+l})$ proceeds as follows: |
3462 | 3456 |
3463 %Furthermore, if $p_k$ is a rest parameter, then one of the following cases hold s: | |
3464 %\begin{enumerate} | |
3465 %\item $m = k-1$. Then $p_k$ is bound to a freshly allocated empty list. \Q{cant we share it? identity?} | |
3466 %\item $m = k$, and $a_k$ is a spread argument ...$e_k$. Then $p_k$ is bound to the value of $e_k$. In checked mode, it is a dynamic type error if the type of $p_k$ is not a supertype of the value of $e_k$. | |
3467 %\item $m \ge k$. A freshly allocated list $r$ of the type of $p_k$ with size $ m - k + 1$ is allocated. and initialized such that $r_j = a_{k+j}, 0 \le j \le m - k$. Then $p_k$ is bound to $r$. | |
3468 %\end{enumerate} | |
3469 | |
3470 %Otherwise, i | |
3471 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}$. | 3457 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}$. |
3472 | 3458 |
3473 \commentary{Simply stated, an argument list consisting of $m$ positional argumen ts and $l$ named arguments is evaluated from left to right. | 3459 \commentary{Simply stated, an argument list consisting of $m$ positional argumen ts and $l$ named arguments is evaluated from left to right. |
3474 } | 3460 } |
3475 | 3461 |
3476 | 3462 |
3477 \subsubsection{ Binding Actuals to Formals} | 3463 \subsubsection{ Binding Actuals to Formals} |
3478 \label{bindingActualsToFormals} | 3464 \label{bindingActualsToFormals} |
3479 | 3465 |
3480 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$. | 3466 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$. |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4384 . | 4370 . |
4385 | 4371 |
4386 | 4372 |
4387 {\bf isOperator:} | 4373 {\bf isOperator:} |
4388 \IS{} `!'? | 4374 \IS{} `!'? |
4389 . | 4375 . |
4390 \end{grammar} | 4376 \end{grammar} |
4391 | 4377 |
4392 Evaluation of the is-expression \code{$e$ \IS{} $T$} proceeds as follows: | 4378 Evaluation of the is-expression \code{$e$ \IS{} $T$} proceeds as follows: |
4393 | 4379 |
4394 The expression $e$ is evaluated to a value $v$. Then, if the interface of the cl ass of $v$ is a subtype of $T$, the is-expression evaluates to true. Otherwise i t evaluates to false. | 4380 The expression $e$ is evaluated to a value $v$. Then, if $T$ is malformed, a dyn amic error occurs. Otherwise, if the interface of the class of $v$ is a subtype of $T$, the is-expression evaluates to true. Otherwise it evaluates to false. |
4395 | 4381 |
4396 \commentary{It follows that \code{$e$ \IS{} Object} is always true. This makes s ense in a language where everything is an object. | 4382 \commentary{It follows that \code{$e$ \IS{} Object} is always true. This makes s ense in a language where everything is an object. |
4397 | 4383 |
4398 Also note that \code{\NULL{} \IS{} $T$} is false unless $T = \code{Object}$, $T = \code{\DYNAMIC{}}$ or $T = \code{Null}$. The former two are useless, as is an ything of the form \code{$e$ \IS{} Object} or \code{$e$ \IS{} \DYNAMIC{}}. User s should test for a null value directly rather than via type tests. | 4384 Also note that \code{\NULL{} \IS{} $T$} is false unless $T = \code{Object}$, $T = \code{\DYNAMIC{}}$ or $T = \code{Null}$. The former two are useless, as is an ything of the form \code{$e$ \IS{} Object} or \code{$e$ \IS{} \DYNAMIC{}}. User s should test for a null value directly rather than via type tests. |
4399 } | 4385 } |
4400 | 4386 |
4401 The is-expression \code{$e$ \IS{}! $T$} is equivalent to \code{!($e$ \IS{} $T$)} . | 4387 The is-expression \code{$e$ \IS{}! $T$} is equivalent to \code{!($e$ \IS{} $T$)} . |
4402 | 4388 |
4403 % Add flow dependent types | 4389 % Add flow dependent types |
4404 | 4390 |
4405 \commentary{ | |
4406 If $T$ is malformed the test always succeeds. This is a consequence of the rule that malformed types are treated as \DYNAMIC{} | |
4407 } | |
4408 %does not denote a type available in the current lexical scope. It is a %compile -time error % CHANGED | |
4409 %run-time error | |
4410 %if $T$ is a parameterized type of the form $G<T_1, \ldots, T_n>$ and $G$ is not a generic type with $n$ type parameters. | |
4411 | |
4412 %Note, that, in checked mode, it is a dynamic type error if a malformed type is used in a type test as specified in \ref{dynamicTypeSystem}. | |
4413 | |
4414 %It is a static warning if $T$ is malformed or malbounded. | |
4415 %does not denote a type available in the current lexical scope. | |
4416 | 4391 |
4417 Let $v$ be a local variable or a formal parameter. An is-expression of the form \code{$v$ \IS{} $T$} shows that $v$ has type $T$ iff $T$ is more specific than the type $S$ of the expression $v$ and both $T \ne \DYNAMIC{}$ and $S \ne \DYN AMIC{}$. | 4392 Let $v$ be a local variable or a formal parameter. An is-expression of the form \code{$v$ \IS{} $T$} shows that $v$ has type $T$ iff $T$ is more specific than the type $S$ of the expression $v$ and both $T \ne \DYNAMIC{}$ and $S \ne \DYN AMIC{}$. |
4418 | 4393 |
4419 \rationale{ | 4394 \rationale{ |
4420 The motivation for the ``shows that v has type T" relation is to reduce spurious warnings thereby enabling a more natural coding style. The rules in the current specification are deliberately kept simple. It would be upwardly compatible to refine these rules in the future; such a refinement would accept more code witho ut warning, but not reject any code now warning-free. | 4395 The motivation for the ``shows that v has type T" relation is to reduce spurious warnings thereby enabling a more natural coding style. The rules in the current specification are deliberately kept simple. It would be upwardly compatible to refine these rules in the future; such a refinement would accept more code witho ut warning, but not reject any code now warning-free. |
4421 | 4396 |
4422 The rule only applies to locals and parameters, as fields could be modified via side-effecting functions or methods that are not accessible to a local analysis. | 4397 The rule only applies to locals and parameters, as fields could be modified via side-effecting functions or methods that are not accessible to a local analysis. |
4423 | 4398 |
4424 It is pointless to deduce a weaker type than what is already known. Furthermore, this would lead to a situation where multiple types are associated with a varia ble at a given point, which complicates the specification. Hence the requirement that $T << S$ (we use $<<$ rather than subtyping because subtyping is not a par tial order). | 4399 It is pointless to deduce a weaker type than what is already known. Furthermore, this would lead to a situation where multiple types are associated with a varia ble at a given point, which complicates the specification. Hence the requirement that $T << S$ (we use $<<$ rather than subtyping because subtyping is not a par tial order). |
4425 | 4400 |
4426 We do not want to refine the type of a variable of type \DYNAMIC{}, as this coul d lead to more warnings rather than less. The opposite requirement, that $T \ne \DYNAMIC{}$ is a safeguard lest $S$ ever be $\bot$. | 4401 We do not want to refine the type of a variable of type \DYNAMIC{}, as this coul d lead to more warnings rather than less. The opposite requirement, that $T \ne \DYNAMIC{}$ is a safeguard lest $S$ ever be $\bot$. |
4427 } | 4402 } |
4428 | 4403 |
4429 The static type of an is-expression is \code{bool}. | 4404 The static type of an is-expression is \code{bool}. |
4430 %It is a static warning if if $T$ is a parameterized type of the form $G<T_1, \l dots, T_n>$ and $G$ is not a generic type with $n$ type parameters. | |
4431 | |
4432 | 4405 |
4433 | 4406 |
4434 \subsection{ Type Cast} | 4407 \subsection{ Type Cast} |
4435 \label{typeCast} | 4408 \label{typeCast} |
4436 | 4409 |
4437 The {\em cast expression} ensures that an object is a member of a type. | 4410 The {\em cast expression} ensures that an object is a member of a type. |
4438 | 4411 |
4439 \begin{grammar} | 4412 \begin{grammar} |
4440 {\bf typeCast:} | 4413 {\bf typeCast:} |
4441 asOperator type | 4414 asOperator type |
4442 . | 4415 . |
4443 | 4416 |
4444 | 4417 |
4445 {\bf asOperator:} | 4418 {\bf asOperator:} |
4446 \AS{} | 4419 \AS{} |
4447 . | 4420 . |
4448 \end{grammar} | 4421 \end{grammar} |
4449 | 4422 |
4450 Evaluation of the cast expression \code{$e$ \AS{} $T$} proceeds as follows: | 4423 Evaluation of the cast expression \code{$e$ \AS{} $T$} proceeds as follows: |
4451 | 4424 |
4452 The expression $e$ is evaluated to a value $v$. Then, if the interface of the cl ass of $v$ is a subtype of $T$, the cast expression evaluates to $v$. Otherwise, if $v$ is \NULL{}, the cast expression evaluates to $v$. | 4425 The expression $e$ is evaluated to a value $v$. Then, if $T$ is malformed, a dyn amic error occurs. Otherwise, if the interface of the class of $v$ is a subtype of $T$, the cast expression evaluates to $v$. Otherwise, if $v$ is \NULL{}, the cast expression evaluates to $v$. |
4453 In all other cases, a \code{CastError} is thrown. | 4426 In all other cases, a \code{CastError} is thrown. |
4454 | 4427 |
4455 \commentary{ | |
4456 If $T$ is malformed the cast always succeeds. This is a consequence of the rule that malformed types are treated as \DYNAMIC{} | |
4457 } | |
4458 | |
4459 %does not denote a type available in the current lexical scope. It is a %compile -time error ; CHANGED | |
4460 %run-time error | |
4461 %if $T$ is a parameterized type of the form $G<T_1, \ldots, T_n>$ and $G$ is not a generic type with $n$ type parameters. | |
4462 | |
4463 %Note, that, in checked mode, it is a dynamic type error if a malformed type is used in a type cast as specified in \ref{dynamicTypeSystem}. | |
4464 | |
4465 %It is a static warning if $T$ is malformed or malbounded. | |
4466 %does not denote a type available in the current lexical scope. | |
4467 The static type of a cast expression \code{$e$ \AS{} $T$} is $T$. | 4428 The static type of a cast expression \code{$e$ \AS{} $T$} is $T$. |
4468 %It is a static warning if if $T$ is a parameterized type of the form $G<T_1, \l dots, T_n>$ and $G$ is not a generic type with $n$ type parameters. | |
4469 | 4429 |
4470 | 4430 |
4471 \section{Statements} | 4431 \section{Statements} |
4472 \label{statements} | 4432 \label{statements} |
4473 | 4433 |
4474 \begin{grammar} | 4434 \begin{grammar} |
4475 {\bf statements:} | 4435 {\bf statements:} |
4476 statement* | 4436 statement* |
4477 . | 4437 . |
4478 | 4438 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4829 | 4789 |
4830 \rationale{ | 4790 \rationale{ |
4831 The prohibition on user defined equality allows us to implement the switch effi ciently for user defined types. We could formulate matching in terms of identity instead with the same efficiency. However, if a type defines an equality operat or, programmers would find it quite surprising that equal objects did not match. | 4791 The prohibition on user defined equality allows us to implement the switch effi ciently for user defined types. We could formulate matching in terms of identity instead with the same efficiency. However, if a type defines an equality operat or, programmers would find it quite surprising that equal objects did not match. |
4832 | 4792 |
4833 } | 4793 } |
4834 | 4794 |
4835 \commentary{ | 4795 \commentary{ |
4836 The \SWITCH{} statement should only be used in very limited situations (e.g., i nterpreters or scanners). | 4796 The \SWITCH{} statement should only be used in very limited situations (e.g., i nterpreters or scanners). |
4837 } | 4797 } |
4838 | 4798 |
4839 %A switch statement {\SWITCH{} ($e$) \{ $label_{11} \ldots label_{1j_1}$ \CASE{ } $e_1: s_1 \ldots$ $label_{n1} \ldots label_{nj_n}$ \CASE{} $e_n: s_n$ \}} is equivalent to switch statement \code{\SWITCH{} ($e$) \{ $label_{11} \ldots label _{1j_1}$ \CASE{} $e_1: s_1 \ldots$ $label_{n1} \ldots label_{nj_n}$ \CASE{} $e _n: s_n$ \DEFAULT{}: \}} | |
4840 | |
4841 Execution of a switch statement of the form \code{\SWITCH{} ($e$) \{ \CASE{} $la bel_{11} \ldots label_{1j_1}$ $e_1: s_1 \ldots$ \CASE{} $label_{n1} \ldots labe l_{nj_n}$ $e_n: s_n$ \DEFAULT{}: $s_{n+1}$ \}} or the form \code{\SWITCH{} ($e$) \{ \CASE{} $label_{11} \ldots label_{1j_1}$ $e_1: s_1 \ldots$ \CASE{} $label_{ n1} \ldots label_{nj_n}$ $e_n: s_n$ \}} proceeds as follows: | 4799 Execution of a switch statement of the form \code{\SWITCH{} ($e$) \{ \CASE{} $la bel_{11} \ldots label_{1j_1}$ $e_1: s_1 \ldots$ \CASE{} $label_{n1} \ldots labe l_{nj_n}$ $e_n: s_n$ \DEFAULT{}: $s_{n+1}$ \}} or the form \code{\SWITCH{} ($e$) \{ \CASE{} $label_{11} \ldots label_{1j_1}$ $e_1: s_1 \ldots$ \CASE{} $label_{ n1} \ldots label_{nj_n}$ $e_n: s_n$ \}} proceeds as follows: |
4842 | 4800 |
4843 The statement \code{\VAR{} id = $e$;} is evaluated, where \code{id} is a variabl e whose name is distinct from any other variable in the program. In checked mode , it is a run time error if the value of $e$ is not an instance of the same clas s as the constants $e_1 \ldots e_n$. | 4801 The statement \code{\VAR{} id = $e$;} is evaluated, where \code{id} is a variabl e whose name is distinct from any other variable in the program. In checked mode , it is a run time error if the value of $e$ is not an instance of the same clas s as the constants $e_1 \ldots e_n$. |
4844 | 4802 |
4845 \commentary{Note that if there are no case clauses ($n = 0$), the type of $e$ do es not matter.} | 4803 \commentary{Note that if there are no case clauses ($n = 0$), the type of $e$ do es not matter.} |
4846 | 4804 |
4847 Next, the case clause \CASE{} $e_{1}: s_{1}$ is executed if it exists. If \CASE{ } $e_{1}: s_{1}$ does not exist, then if there is a \DEFAULT{} clause it is exe cuted by executing $s_{n+1}$. | 4805 Next, the case clause \CASE{} $e_{1}: s_{1}$ is executed if it exists. If \CASE{ } $e_{1}: s_{1}$ does not exist, then if there is a \DEFAULT{} clause it is exe cuted by executing $s_{n+1}$. |
4848 | 4806 |
4849 A case clause introduces a new scope, nested in the lexically surrounding scope. The scope of a case clause ends immediately after the case clause's statement l ist. | 4807 A case clause introduces a new scope, nested in the lexically surrounding scope. The scope of a case clause ends immediately after the case clause's statement l ist. |
4850 | 4808 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4937 \item | 4895 \item |
4938 A set of \ON{}-\CATCH{} clauses, each of which specifies (either explicitly or implicitly) the type of exception object to be handled, one or two exception par ameters and a block statement. | 4896 A set of \ON{}-\CATCH{} clauses, each of which specifies (either explicitly or implicitly) the type of exception object to be handled, one or two exception par ameters and a block statement. |
4939 \item | 4897 \item |
4940 A \FINALLY{} clause, which consists of a block statement. | 4898 A \FINALLY{} clause, which consists of a block statement. |
4941 \end{enumerate} | 4899 \end{enumerate} |
4942 | 4900 |
4943 \rationale{ | 4901 \rationale{ |
4944 The syntax is designed to be upward compatible with existing Javascript programs . The \ON{} clause can be omitted, leaving what looks like a Javascript catch cl ause. | 4902 The syntax is designed to be upward compatible with existing Javascript programs . The \ON{} clause can be omitted, leaving what looks like a Javascript catch cl ause. |
4945 } | 4903 } |
4946 | 4904 |
4947 An \ON{}-\CATCH{} clause of the form \code{\ON{} $T$ \CATCH{} ($p_1, p_2$) $ s$} {\em matches} an object $o$ if the type of $o$ is a subtype of $T$. | 4905 An \ON{}-\CATCH{} clause of the form \code{\ON{} $T$ \CATCH{} ($p_1, p_2$) $ s$} {\em matches} an object $o$ if the type of $o$ is a subtype of $T$. If $T $ is a malformed type, then performing a match causes a run time error. |
4948 | 4906 |
4949 \commentary { | 4907 \commentary { |
4950 It is of course a static warning if $T$ is a malformed type (\ref{staticTypes}). | 4908 It is of course a static warning if $T$ is a malformed type (\ref{staticTypes}). |
4951 } | 4909 } |
4952 | 4910 |
4953 An \ON{}-\CATCH{} clause of the form \code{\ON{} $T$ \CATCH{} ($p_1$) $s$} is e quivalent to an \ON{}-\CATCH{} clause \code{\ON{} $T$ \CATCH{} ($p_1, p_2$) $s$ } where $p_2$ is an identifier that does not occur anywhere else in the program. | 4911 An \ON{}-\CATCH{} clause of the form \code{\ON{} $T$ \CATCH{} ($p_1$) $s$} is e quivalent to an \ON{}-\CATCH{} clause \code{\ON{} $T$ \CATCH{} ($p_1, p_2$) $s$ } where $p_2$ is an identifier that does not occur anywhere else in the program. |
4954 | 4912 |
4955 | 4913 |
4956 An \ON{}-\CATCH{} clause of the form \code{\CATCH{} ($p$) $s$} is equivalent to an \ON{}-\CATCH{} clause \code{\ON{} \DYNAMIC{} \CATCH{} ($p$) $s$}. An \ON{}- \CATCH{} clause of the form \code{\CATCH{} ($p_1, p_2$) $s$} is equivalent to a n \ON{}-\CATCH{} clause \code{\ON{} \DYNAMIC{} \CATCH{} ($p_1, p_2$) $s$} | 4914 An \ON{}-\CATCH{} clause of the form \code{\CATCH{} ($p$) $s$} is equivalent to an \ON{}-\CATCH{} clause \code{\ON{} \DYNAMIC{} \CATCH{} ($p$) $s$}. An \ON{}- \CATCH{} clause of the form \code{\CATCH{} ($p_1, p_2$) $s$} is equivalent to a n \ON{}-\CATCH{} clause \code{\ON{} \DYNAMIC{} \CATCH{} ($p_1, p_2$) $s$} |
4957 | 4915 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5475 . | 5433 . |
5476 \end{grammar} | 5434 \end{grammar} |
5477 | 5435 |
5478 A {\em part header} begins with \PART{} \OF{} followed by the name of the libr ary the part belongs to. A part declaration consists of a part header followed by a sequence of top-level declarations. | 5436 A {\em part header} begins with \PART{} \OF{} followed by the name of the libr ary the part belongs to. A part declaration consists of a part header followed by a sequence of top-level declarations. |
5479 | 5437 |
5480 Compiling a part directive of the form \code{\PART{} $s$;} causes the Dart syste m to attempt to compile the contents of the URI that is the value of $s$. The to p-level declarations at that URI are then compiled by the Dart compiler in the s cope of the current library. It is a compile-time error if the contents of the U RI are not a valid part declaration. It is a static warning if the referenced pa rt declaration $p$ names a library other than the current library as the library to which $p$ belongs. | 5438 Compiling a part directive of the form \code{\PART{} $s$;} causes the Dart syste m to attempt to compile the contents of the URI that is the value of $s$. The to p-level declarations at that URI are then compiled by the Dart compiler in the s cope of the current library. It is a compile-time error if the contents of the U RI are not a valid part declaration. It is a static warning if the referenced pa rt declaration $p$ names a library other than the current library as the library to which $p$ belongs. |
5481 | 5439 |
5482 \subsection{Scripts} | 5440 \subsection{Scripts} |
5483 \label{scripts} | 5441 \label{scripts} |
5484 | 5442 |
5485 A {\em script} is a library with a top-level function \code{main()}. | 5443 A {\em script} is a library whose exported namespace (\ref{exports}) includes a top-level function \code{main()}. |
5486 A script $S$ may be executed as follows: | 5444 A script $S$ may be executed as follows: |
5487 | 5445 |
5488 First, $S$ is compiled as a library as specified above. Then, the top-level func tion \code{main()} that is in scope in $S$ is invoked with no arguments. It is a run time error if $S$ does not declare or import a top-level function \code{mai n()}. | 5446 First, $S$ is compiled as a library as specified above. Then, the top-level func tion \code{main()} that is in the exported namespace of $S$ is invoked with no a rguments. It is a run time error if $S$ does not declare or import a top-level f unction \code{main()}. |
5489 | 5447 |
5490 \rationale{ | 5448 \rationale{ |
5491 The names of scripts are optional, in the interests of interactive, informal use . However, any script of long term value should be given a name as a matter of g ood practice. | 5449 The names of scripts are optional, in the interests of interactive, informal use . However, any script of long term value should be given a name as a matter of g ood practice. |
5492 } | 5450 } |
5493 | 5451 |
5452 \commentary { | |
5453 A Dart program will typically be executed by executing a script. | |
5454 } | |
5455 | |
5494 \subsection{URIs} | 5456 \subsection{URIs} |
5495 \label{uris} | 5457 \label{uris} |
5496 | 5458 |
5497 URIs are specified by means of string literals: | 5459 URIs are specified by means of string literals: |
5498 | 5460 |
5499 \begin{grammar} | 5461 \begin{grammar} |
5500 {\bf uri:} | 5462 {\bf uri:} |
5501 stringLiteral | 5463 stringLiteral |
5502 . | 5464 . |
5503 \end{grammar} | 5465 \end{grammar} |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5574 \item $T$ has the form $id$ or the form $prefix.id$, and in the enclosing lexica l scope, the name $id$ (respectively $prefix.id$) does not denote a type. | 5536 \item $T$ has the form $id$ or the form $prefix.id$, and in the enclosing lexica l scope, the name $id$ (respectively $prefix.id$) does not denote a type. |
5575 \item $T$ denotes a type variable in the enclosing lexical scope, but occurs in the signature or body of a static member. | 5537 \item $T$ denotes a type variable in the enclosing lexical scope, but occurs in the signature or body of a static member. |
5576 \item $T$ is a parameterized type of the form $G<S_1, \ldots , S_n>$, and $G$ i s malformed. | 5538 \item $T$ is a parameterized type of the form $G<S_1, \ldots , S_n>$, and $G$ i s malformed. |
5577 \item $T$ denotes declarations that were imported from multiple imports clauses. | 5539 \item $T$ denotes declarations that were imported from multiple imports clauses. |
5578 %Either $G$ or $S_i, i \in 1.. n$ are malformed. | 5540 %Either $G$ or $S_i, i \in 1.. n$ are malformed. |
5579 % \item $G$ is not a generic type with $n$ type parameters. | 5541 % \item $G$ is not a generic type with $n$ type parameters. |
5580 % \item Let $T_i$ be the type parameters of $G$ (if any) and let $B_i$ be the b ound of $T_i, i \in 1.. n$, and $S_i$ is not a subtype of $[S_1, \ldots, S_n/T _1, \ldots, T_n]B_i, i \in 1.. n$. | 5542 % \item Let $T_i$ be the type parameters of $G$ (if any) and let $B_i$ be the b ound of $T_i, i \in 1.. n$, and $S_i$ is not a subtype of $[S_1, \ldots, S_n/T _1, \ldots, T_n]B_i, i \in 1.. n$. |
5581 % \end{itemize} | 5543 % \end{itemize} |
5582 \end{itemize} | 5544 \end{itemize} |
5583 | 5545 |
5584 Any use of a malformed type gives rise to a static warning. A malformed type i s then interpreted as \DYNAMIC{} by the static type checker and the runtime. | 5546 Any use of a malformed type gives rise to a static warning. A malformed type i s then interpreted as \DYNAMIC{} by the static type checker and the runtime unle ss explicitly specified otherwise. |
5585 | 5547 |
5586 \rationale{ | 5548 \rationale{ |
5587 This ensures that the developer is spared a series of cascading warnings as the malformed type interacts with other types. | 5549 This ensures that the developer is spared a series of cascading warnings as the malformed type interacts with other types. |
5588 } | 5550 } |
5589 | 5551 |
5552 | |
5590 \subsubsection{Type Promotion} | 5553 \subsubsection{Type Promotion} |
5591 \label{typePromotion} | 5554 \label{typePromotion} |
5592 | 5555 |
5593 The static type system ascribes a static type to every expression. In some case s, the types of local variables and formal parameters may be promoted from their declared types based on control flow. | 5556 The static type system ascribes a static type to every expression. In some case s, the types of local variables and formal parameters may be promoted from their declared types based on control flow. |
5594 | 5557 |
5595 We say that a variable $v$ is known to have type $T$ whenever we allow the type of $v$ to be promoted. The exact circumstances when type promotion is allowed ar e given in the relevant sections of the specification (\ref{logicalBooleanExpres sions}, \ref{conditional} and \ref{if}). | 5558 We say that a variable $v$ is known to have type $T$ whenever we allow the type of $v$ to be promoted. The exact circumstances when type promotion is allowed ar e given in the relevant sections of the specification (\ref{logicalBooleanExpres sions}, \ref{conditional} and \ref{if}). |
5596 | 5559 |
5597 Type promotion for a variable $v$ is allowed only when we can deduce that such p romotion is valid based on an analysis of certain boolean expressions. In such c ases, we say that the boolean expression $b$ shows that $v$ has type $T$. As a r ule, for all variables $v$ and types $T$, a boolean expression does not show tha t $v$ has type $T$. Those situations where an expression does show that a variab le has a type are mentioned explicitly in the relevant sections of this specific ation (\ref{typeTest} and \ref{logicalBooleanExpressions}). | 5560 Type promotion for a variable $v$ is allowed only when we can deduce that such p romotion is valid based on an analysis of certain boolean expressions. In such c ases, we say that the boolean expression $b$ shows that $v$ has type $T$. As a r ule, for all variables $v$ and types $T$, a boolean expression does not show tha t $v$ has type $T$. Those situations where an expression does show that a variab le has a type are mentioned explicitly in the relevant sections of this specific ation (\ref{typeTest} and \ref{logicalBooleanExpressions}). |
5598 | 5561 |
5599 | 5562 |
5600 \subsection{Dynamic Type System} | 5563 \subsection{Dynamic Type System} |
5601 \label{dynamicTypeSystem} | 5564 \label{dynamicTypeSystem} |
5602 | 5565 |
5603 A Dart implementation must support execution in both {\em production mode} and { \em checked mode}. Those dynamic checks specified as occurring specifically in checked mode must be performed iff the code is executed in checked mode. | 5566 A Dart implementation must support execution in both {\em production mode} and { \em checked mode}. Those dynamic checks specified as occurring specifically in checked mode must be performed iff the code is executed in checked mode. |
5604 | 5567 |
5605 %It is a run-time type error to access an undeclared type outside . | 5568 %It is a run-time type error to access an undeclared type outside . |
5606 | 5569 |
5607 %It is a dynamic type error if a malformed type is used in a subtype test. | 5570 %It is a dynamic type error if a malformed type is used in a subtype test. |
5608 In checked mode, it is a dynamic type error if a malbounded (\ref{parameterized Types}) | 5571 In checked mode, it is a dynamic type error if a malformed or malbounded (\ref{p arameterizedTypes}) |
5609 type is used in a subtype test. | 5572 type is used in a subtype test. |
5610 | 5573 |
5611 %In production mode, an undeclared type is treated as an instance of type \DYNAM IC{}. | 5574 %In production mode, an undeclared type is treated as an instance of type \DYNAM IC{}. |
5612 | 5575 |
5613 \commentary{Consider the following program} | 5576 \commentary{Consider the following program} |
5614 | 5577 |
5615 \begin{dartCode} | 5578 \begin{dartCode} |
5616 \TYPEDEF{} F(bool x); | 5579 \TYPEDEF{} F(bool x); |
5617 f(foo x) $=>$ x; | 5580 f(foo x) $=>$ x; |
5618 main() \{ | 5581 main() \{ |
(...skipping 11 matching lines...) Expand all Loading... | |
5630 | 5593 |
5631 \begin{dartCode} | 5594 \begin{dartCode} |
5632 \VAR{} i; | 5595 \VAR{} i; |
5633 i j; // a variable j of type i (supposedly) | 5596 i j; // a variable j of type i (supposedly) |
5634 main() \{ | 5597 main() \{ |
5635 j = 'I am not an i'; | 5598 j = 'I am not an i'; |
5636 \} | 5599 \} |
5637 \end{dartCode} | 5600 \end{dartCode} |
5638 | 5601 |
5639 \commentary{ | 5602 \commentary{ |
5640 Since $i$ is not a type, a static warning will be issue at the declaration of $j $. However, the program can be executed without incident. The undeclared type $ i$ is treated as \DYNAMIC{}, so even in checked mode, the implicit subtype test at the assignment succeeds. | 5603 Since $i$ is not a type, a static warning will be issue at the declaration of $j $. However, the program can be executed without incident in production mode beca use he undeclared type $i$ is treated as \DYNAMIC{}. However, in checked mode, t he implicit subtype test at the assignment will trigger an error at runtime. |
Johnni Winther
2013/11/04 12:34:49
'because he undeclared' -> 'because the undeclared
| |
5641 } | 5604 } |
5642 | 5605 |
5643 \rationale{ | |
5644 We have chosen to treat malformed types as type \DYNAMIC{}. Earlier versions of this specification did so in some cases but not in others. We found the rules t o be too complex, and have opted to harmonize the specification. Given that a st atic warning is issued, there is no need for the runtime to deal with extra comp lexity by treating malformed types specially. | |
5645 | |
5646 | |
5647 %as is done in production mode. After all, a static warning has already been giv en. That is a legitimate design option, and it is ultimately a judgement call as to whether checked mode should be more or less aggressive in dealing with such a situation. | |
5648 | |
5649 %Likewise, we could opt to ignore malformed types entirely in checked mode. | |
5650 | |
5651 %For now, we have opted to treat a malformed type as an error type that has no s ubtypes or supertypes, and which causes a runtime error when tested against any other type. | |
5652 } | |
5653 | 5606 |
5654 \commentary{ | 5607 \commentary{ |
5655 Here is an example involving malbounded types: | 5608 Here is an example involving malbounded types: |
5656 } | 5609 } |
5657 | 5610 |
5658 \begin{dartCode} | 5611 \begin{dartCode} |
5659 \CLASS{} I$<$T \EXTENDS{} num$>$ \{\} | 5612 \CLASS{} I$<$T \EXTENDS{} num$>$ \{\} |
5660 \CLASS{} J \{\} | 5613 \CLASS{} J \{\} |
5661 | 5614 |
5662 \CLASS{} A$<$T$>$ \IMPLEMENTS{} J, I$<$T$>$ // type warning: T is not a subtype of num | 5615 \CLASS{} A$<$T$>$ \IMPLEMENTS{} J, I$<$T$>$ // type warning: T is not a subtype of num |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6161 \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. | 6114 \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. |
6162 \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 | 6115 \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 |
6163 \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. | 6116 \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. |
6164 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E. | 6117 \item The names of type variables are short (preferably single letter). Examples : T, S, K, V , E. |
6165 \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. | 6118 \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. |
6166 \end{itemize} | 6119 \end{itemize} |
6167 } | 6120 } |
6168 | 6121 |
6169 | 6122 |
6170 \end{document} | 6123 \end{document} |
OLD | NEW |