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 \newcommand{\code}[1]{{\sf #1}} | 8 \newcommand{\code}[1]{{\sf #1}} |
9 \title{Dart Programming Language Specification \\ | 9 \title{Dart Programming Language Specification \\ |
10 {4th edition draft}\\ | 10 {4th edition draft}\\ |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 It is a compile-time error if an \ASYNC, \ASYNC* or \SYNC* modifier is attached
to the body of a setter or constructor. | 585 It is a compile-time error if an \ASYNC, \ASYNC* or \SYNC* modifier is attached
to the body of a setter or constructor. |
586 | 586 |
587 \rationale{ | 587 \rationale{ |
588 An asynchronous setter would be of little use, since setters can only be used in
the context of an assignment (\ref{assignment}), and an assignment expression a
lways evaluates to the value of the assignment's right hand side. If the setter
actually did its work asynchronously, one might imagine that one would return a
future that resolved to the assignment's right hand side after the setter did it
s work. However, this would require dynamic tests at every assignment, and so wo
uld be prohibitively expensive. | 588 An asynchronous setter would be of little use, since setters can only be used in
the context of an assignment (\ref{assignment}), and an assignment expression a
lways evaluates to the value of the assignment's right hand side. If the setter
actually did its work asynchronously, one might imagine that one would return a
future that resolved to the assignment's right hand side after the setter did it
s work. However, this would require dynamic tests at every assignment, and so wo
uld be prohibitively expensive. |
589 | 589 |
590 An asynchronous constructor would, by definition, never return an instance of th
e class it purports to construct, but instead return a future. Calling such a be
ast via \NEW{} would be very confusing. If you need to produce an object asynchr
onously, use a method. | 590 An asynchronous constructor would, by definition, never return an instance of th
e class it purports to construct, but instead return a future. Calling such a be
ast via \NEW{} would be very confusing. If you need to produce an object asynchr
onously, use a method. |
591 | 591 |
592 One could allow modifiers for factories. A factory for \code{Future} could be mo
dified by \ASYNC{}, a factory for \code{Stream} could be modified by \ASYNC* and
a factory for \code{Iterable} could be modified by \SYNC*. No other scenario ma
kes sense because the object returned by the factory would be of the wrong type.
This situation is very unusual so it is not worth making an exception to the ge
neral rule for constructors in order to allow it. | 592 One could allow modifiers for factories. A factory for \code{Future} could be mo
dified by \ASYNC{}, a factory for \code{Stream} could be modified by \ASYNC* and
a factory for \code{Iterable} could be modified by \SYNC*. No other scenario ma
kes sense because the object returned by the factory would be of the wrong type.
This situation is very unusual so it is not worth making an exception to the ge
neral rule for constructors in order to allow it. |
593 } | 593 } |
594 \LMHash{} | 594 \LMHash{} |
595 It is a static warning if the declared return type of a function marked \ASYNC{}
may not be assigned to \code{Future}. It is a static warning if the declared re
turn type of a function marked \SYNC* may not be assigned to \code{Iterable}. It
is a static warning if the declared return type of a function marked \ASYNC* m
ay not be assigned to \code{Stream}. | 595 It is a static warning if the declared return type of a function marked \ASYNC{}
is not a supertype of \code{Future$<$\mbox{$T$}$>$} for some type $T$. |
| 596 It is a static warning if the declared return type of a function marked \SYNC* i
s not a supertype of \code{Iterable$<$\mbox{$T$}$>$} for some type $T$. |
| 597 It is a static warning if the declared return type of a function marked \ASYNC*
is not a supertype of \code{Stream$<$\mbox{$T$}$>$} for some type $T$. |
596 | 598 |
597 \subsection{Function Declarations} | 599 \subsection{Function Declarations} |
598 \LMLabel{functionDeclarations} | 600 \LMLabel{functionDeclarations} |
599 | 601 |
600 \LMHash{} | 602 \LMHash{} |
601 A {\em function declaration} is a function that is neither a member of a class n
or a function literal. Function declarations include {\em library functions}, wh
ich are function declarations | 603 A {\em function declaration} is a function that is neither a member of a class n
or a function literal. Function declarations include {\em library functions}, wh
ich are function declarations |
602 %(including getters and setters) | 604 %(including getters and setters) |
603 at the top level of a library, and {\em local functions}, which are function dec
larations declared inside other functions. Library functions are often referred
to simply as top-level functions. | 605 at the top level of a library, and {\em local functions}, which are function dec
larations declared inside other functions. Library functions are often referred
to simply as top-level functions. |
604 | 606 |
605 \LMHash{} | 607 \LMHash{} |
(...skipping 7290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7896 | 7898 |
7897 The invariant that each normative paragraph is associated with a line | 7899 The invariant that each normative paragraph is associated with a line |
7898 containing the text \LMHash{} should be maintained. Extra occurrences | 7900 containing the text \LMHash{} should be maintained. Extra occurrences |
7899 of \LMHash{} can be added if needed, e.g., in order to make | 7901 of \LMHash{} can be added if needed, e.g., in order to make |
7900 individual \item{}s in itemized lists addressable. Each \LM.. command | 7902 individual \item{}s in itemized lists addressable. Each \LM.. command |
7901 must occur on a separate line. \LMHash{} must occur immediately | 7903 must occur on a separate line. \LMHash{} must occur immediately |
7902 before the associated paragraph, and \LMLabel must occur immediately | 7904 before the associated paragraph, and \LMLabel must occur immediately |
7903 after the associated \section{}, \subsection{} etc. | 7905 after the associated \section{}, \subsection{} etc. |
7904 | 7906 |
7905 ---------------------------------------------------------------------- | 7907 ---------------------------------------------------------------------- |
OLD | NEW |