OLD | NEW |
---|---|
1 \documentclass{article} | 1 \documentclass{article} |
2 \usepackage{epsfig} | 2 \usepackage{epsfig} |
3 \usepackage{color} | 3 \usepackage{color} |
4 \usepackage{dart} | 4 \usepackage{dart} |
5 \usepackage{bnf} | 5 \usepackage{bnf} |
6 \usepackage{hyperref} | 6 \usepackage{hyperref} |
7 \usepackage{lmodern} | 7 \usepackage{lmodern} |
8 \usepackage[T1]{fontenc} | 8 \usepackage[T1]{fontenc} |
9 \newcommand{\code}[1]{{\sf #1}} | 9 \newcommand{\code}[1]{{\sf #1}} |
10 \title{Dart Programming Language Specification \\ | 10 \title{Dart Programming Language Specification \\ |
11 {5th edition draft}\\ | 11 {5th edition draft}\\ |
12 {\large Version 1.15.0}} | 12 {\large Version 1.15.0}} |
13 | 13 |
14 % For information about Location Markers (and in particular the | 14 % For information about Location Markers (and in particular the |
15 % commands \LMHash and \LMLabel), see the long comment at the | 15 % commands \LMHash and \LMLabel), see the long comment at the |
16 % end of this file. | 16 % end of this file. |
17 | 17 |
18 % CHANGES | 18 % CHANGES |
19 % ======= | 19 % ======= |
20 % Significant changes to the specification. | 20 % Significant changes to the specification. |
21 % | 21 % |
22 % 1.15 | 22 % 1.15 |
23 % - Change how language specification describes control flow. | 23 % - Change how language specification describes control flow. |
24 % - Object initialization now specifies initialization order correctly. | 24 % - Object initialization now specifies initialization order correctly. |
25 % - Specifies that leaving an await-for loop must wait for the subscription | 25 % - Specifies that leaving an await-for loop must wait for the subscription |
26 % to be canceled. | 26 % to be canceled. |
27 % - An await-for loop only pauses the subscription if it does something async. | 27 % - An await-for loop only pauses the subscription if it does something async. |
28 % - Assert statements may now also include a "message" operand. | 28 % - Assert statements may now also include a "message" operand. |
29 % - The Null type is now considered a subtype of all types in most cases. | 29 % - The Null type is now considered a subtype of all types in most cases. |
30 % - Specified the FutureOf type. | |
eernst
2017/02/01 16:54:30
`FutureOr`. Also, it seems to be the standard styl
| |
30 % | 31 % |
31 % 1.14 | 32 % 1.14 |
32 % - The call "C()" where "C" is a class name, is a now compile-time error. | 33 % - The call "C()" where "C" is a class name, is a now compile-time error. |
33 % - Changed description of rewrites that depended on a function literal. | 34 % - Changed description of rewrites that depended on a function literal. |
34 % In many cases, the rewrite wasn't safe for asynchronous code. | 35 % In many cases, the rewrite wasn't safe for asynchronous code. |
35 % - Removed generalized tear-offs. | 36 % - Removed generalized tear-offs. |
36 % - Allow "rethrow" to also end a switch case. Allow braces around switch cases. | 37 % - Allow "rethrow" to also end a switch case. Allow braces around switch cases. |
37 % - Allow using '=' as default-value separator for named parameters. | 38 % - Allow using '=' as default-value separator for named parameters. |
38 % - Make it a compile-time error if a library includes the same part twice. | 39 % - Make it a compile-time error if a library includes the same part twice. |
39 % - Now more specific about the return types of sync*/async/async* functions | 40 % - Now more specific about the return types of sync*/async/async* functions |
(...skipping 7179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7219 \begin{grammar} | 7220 \begin{grammar} |
7220 {\bf type:} | 7221 {\bf type:} |
7221 typeName typeArguments? | 7222 typeName typeArguments? |
7222 . | 7223 . |
7223 | 7224 |
7224 {\bf typeName:} | 7225 {\bf typeName:} |
7225 qualified | 7226 qualified |
7226 . | 7227 . |
7227 | 7228 |
7228 {\bf typeArguments:} | 7229 {\bf typeArguments:} |
7229 '<' typeList '>' | 7230 `<' typeList `>' |
7230 . | 7231 . |
7231 | 7232 |
7232 {\bf typeList:} | 7233 {\bf typeList:} |
7233 type (',' type)* | 7234 type (`,' type)* |
7234 . | 7235 . |
7235 \end{grammar} | 7236 \end{grammar} |
7236 | 7237 |
7237 \LMHash{} | 7238 \LMHash{} |
7238 A Dart implementation must provide a static checker that detects and reports exa ctly those situations this specification identifies as static warnings and only those situations. However: | 7239 A Dart implementation must provide a static checker that detects and reports exa ctly those situations this specification identifies as static warnings and only those situations. However: |
7239 \begin{itemize} | 7240 \begin{itemize} |
7240 \item Running the static checker on a program $P$ is not required for compiling and running $P$. | 7241 \item Running the static checker on a program $P$ is not required for compiling and running $P$. |
7241 \item Running the static checker on a program $P$ must not prevent successful co mpilation of $P$ nor may it prevent the execution of $P$, regardless of whether any static warnings occur. | 7242 \item Running the static checker on a program $P$ must not prevent successful co mpilation of $P$ nor may it prevent the execution of $P$, regardless of whether any static warnings occur. |
7242 \end{itemize} | 7243 \end{itemize} |
7243 | 7244 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7644 (3) \code{typedAPI(new G\lt{String}\gt());} | 7645 (3) \code{typedAPI(new G\lt{String}\gt());} |
7645 | 7646 |
7646 This forces users to write type information in their client code just because th ey are calling a typed API. We do not want to impose this on Dart programmers, some of which may be blissfully unaware of types in general, and genericity in p articular. | 7647 This forces users to write type information in their client code just because th ey are calling a typed API. We do not want to impose this on Dart programmers, some of which may be blissfully unaware of types in general, and genericity in p articular. |
7647 | 7648 |
7648 What of static checking? Surely we would want to flag (2) when users have explic itly asked for static typechecking? Yes, but the reality is that the Dart static checker is likely to be running in the background by default. Engineering teams typically desire a ``clean build'' free of warnings and so the checker is desig ned to be extremely charitable. Other tools can interpret the type information m ore aggressively and warn about violations of conventional (and sound) static ty pe discipline. | 7649 What of static checking? Surely we would want to flag (2) when users have explic itly asked for static typechecking? Yes, but the reality is that the Dart static checker is likely to be running in the background by default. Engineering teams typically desire a ``clean build'' free of warnings and so the checker is desig ned to be extremely charitable. Other tools can interpret the type information m ore aggressively and warn about violations of conventional (and sound) static ty pe discipline. |
7649 } | 7650 } |
7650 | 7651 |
7651 \LMHash{} | 7652 \LMHash{} |
7652 The name \DYNAMIC{} denotes a \cd{Type} object even though \DYNAMIC{} is not a c lass. | 7653 The name \DYNAMIC{} denotes a \cd{Type} object even though \DYNAMIC{} is not a c lass. |
7653 | 7654 |
7655 \LMHash{} | |
7656 The built-in type declaration \code{FutureOr}, | |
7657 which is declared in the library \code{dart:async}, | |
7658 defines a generic type with one type parameter (\ref{generics}). | |
7659 If the \code{FutureOr} type, optionally followed by type arguments, | |
7660 is used as a type, it denotes the \DYNAMIC{} type. | |
7661 As such, the \code{FutureOr} type cannot be used where \DYNAMIC{} cannot be | |
7662 used as a type. | |
7663 If the type arguments applied to \code{FutureOr} would issue static warnings | |
7664 if applied to a normal generic class with one type parameter, | |
7665 the same warnings are issued for \code{FutureOr}, | |
7666 even though the type arguments are otherwise ignored. | |
7667 The name \code{FutureOr} denotes the same \cd{Type} object as \DYNAMIC{}. | |
eernst
2017/02/01 16:54:30
This raises the question: So what's the semantics
Lasse Reichstein Nielsen
2017/02/02 06:45:47
I'm not sure what this is suggesting.
You can't ev
| |
7668 | |
7669 \rationale{ | |
7670 The \code{FutureOr} type is reserved for future use, | |
7671 for cases where a value can be either an instance of the type \metavar{type} | |
7672 or the type \code{Future<\metavar{type}>}. Such cases occur naturally | |
7673 in asynchronous code. | |
7674 Using \code{FutureOr} instead of \DYNAMIC{} will allow some tools | |
7675 to provide a more precise type analysis. | |
7676 } | |
7654 %\rationale { | 7677 %\rationale { |
7655 %Type objects reify the runtime types of instances. No instance ever has type \D YNAMIC{}. | 7678 %Type objects reify the runtime types of instances. No instance ever has type \D YNAMIC{}. |
7656 %} | 7679 %} |
7657 | 7680 |
7658 \subsection{Type Void} | 7681 \subsection{Type Void} |
7659 \LMLabel{typeVoid} | 7682 \LMLabel{typeVoid} |
7660 | 7683 |
7661 \LMHash{} | 7684 \LMHash{} |
7662 The special type \VOID{} may only be used as the return type of a function: it i s a compile-time error to use \VOID{} in any other context. | 7685 The special type \VOID{} may only be used as the return type of a function: it i s a compile-time error to use \VOID{} in any other context. |
7663 | 7686 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8087 | 8110 |
8088 The invariant that each normative paragraph is associated with a line | 8111 The invariant that each normative paragraph is associated with a line |
8089 containing the text \LMHash{} should be maintained. Extra occurrences | 8112 containing the text \LMHash{} should be maintained. Extra occurrences |
8090 of \LMHash{} can be added if needed, e.g., in order to make | 8113 of \LMHash{} can be added if needed, e.g., in order to make |
8091 individual \item{}s in itemized lists addressable. Each \LM.. command | 8114 individual \item{}s in itemized lists addressable. Each \LM.. command |
8092 must occur on a separate line. \LMHash{} must occur immediately | 8115 must occur on a separate line. \LMHash{} must occur immediately |
8093 before the associated paragraph, and \LMLabel must occur immediately | 8116 before the associated paragraph, and \LMLabel must occur immediately |
8094 after the associated \section{}, \subsection{} etc. | 8117 after the associated \section{}, \subsection{} etc. |
8095 | 8118 |
8096 ---------------------------------------------------------------------- | 8119 ---------------------------------------------------------------------- |
OLD | NEW |