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 {\large Version 1.9}} | 10 {\large Version 1.9}} |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 % so does an abstract method override a method in a superclass or not? Does the
superclass method get inherited or not? This generally makes the spec inconsist
ent, as there is no simple answer. | 1099 % so does an abstract method override a method in a superclass or not? Does the
superclass method get inherited or not? This generally makes the spec inconsist
ent, as there is no simple answer. |
1100 % For example - if we say it does not override, then the superclass member is in
herited, in which case the rules for warning break down, and also there is quest
ion of whether there are two definitions of the same name. | 1100 % For example - if we say it does not override, then the superclass member is in
herited, in which case the rules for warning break down, and also there is quest
ion of whether there are two definitions of the same name. |
1101 % But if we do override, method lookup rules break down. So several things need
revisiting. | 1101 % But if we do override, method lookup rules break down. So several things need
revisiting. |
1102 | 1102 |
1103 \rationale{ | 1103 \rationale{ |
1104 The purpose of an abstract method is to provide a declaration for purposes such
as type checking and reflection. In classes used as mixins, it is often useful t
o introduce such declarations for methods that the mixin expects will be provide
d by the superclass the mixin is applied to. | 1104 The purpose of an abstract method is to provide a declaration for purposes such
as type checking and reflection. In classes used as mixins, it is often useful t
o introduce such declarations for methods that the mixin expects will be provide
d by the superclass the mixin is applied to. |
1105 } | 1105 } |
1106 %always results in a run-time error. This must be \code{NoSuchMethodError} or an
instance of a subclass of \code{NoSuchMethodError}, such as \code{AbstractMetho
dError}. | 1106 %always results in a run-time error. This must be \code{NoSuchMethodError} or an
instance of a subclass of \code{NoSuchMethodError}, such as \code{AbstractMetho
dError}. |
1107 | 1107 |
1108 \LMHash{} | 1108 \LMHash{} |
1109 It is a static warning if an abstract member is declared or inherited in a concr
ete class unless that member overrides a concrete one. | 1109 It is a static warning if an abstract member $m$ is declared or inherited in a c
oncrete class $C$ unless: |
| 1110 \begin{itemize} |
| 1111 \item $m$ overrides a concrete member, or |
| 1112 \item $C$ has a \cd{noSuchMethod()} method distinct from the one declared in cla
ss \cd{Object}. |
| 1113 \end{itemize} |
1110 | 1114 |
1111 \rationale { | 1115 \rationale { |
1112 We wish to warn if one declares a concrete class with abstract members. However,
code like the following should work without warnings: | 1116 We wish to warn if one declares a concrete class with abstract members. However,
code like the following should work without warnings: |
1113 } | 1117 } |
1114 | 1118 |
1115 \begin{dartCode} | 1119 \begin{dartCode} |
1116 class Base \{ | 1120 class Base \{ |
1117 int get one =$>$ 1; | 1121 int get one =$>$ 1; |
1118 \} | 1122 \} |
1119 | 1123 |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 \item It is a static warning if a concrete class has an abstract member (declare
d or inherited). | 1810 \item It is a static warning if a concrete class has an abstract member (declare
d or inherited). |
1807 \item It is a static warning and a dynamic error to call a non-factory construct
or of an abstract class (\ref{new}). | 1811 \item It is a static warning and a dynamic error to call a non-factory construct
or of an abstract class (\ref{new}). |
1808 \item If a class defines an instance member named $m$, and any of its superinter
faces have a member named $m$, the interface of the class overrides $m$. | 1812 \item If a class defines an instance member named $m$, and any of its superinter
faces have a member named $m$, the interface of the class overrides $m$. |
1809 \item An interface inherits all members of its superinterfaces that are not ov
erridden and not members of multiple superinterfaces. | 1813 \item An interface inherits all members of its superinterfaces that are not ov
erridden and not members of multiple superinterfaces. |
1810 \item If multiple superinterfaces of an interface define a member with the same
name $m$, then at most one member is inherited. That member (if it exists) is t
he one whose type is a subtype of all the others. If there is no such member, th
en: | 1814 \item If multiple superinterfaces of an interface define a member with the same
name $m$, then at most one member is inherited. That member (if it exists) is t
he one whose type is a subtype of all the others. If there is no such member, th
en: |
1811 \begin{itemize} | 1815 \begin{itemize} |
1812 \item A static warning is given. | 1816 \item A static warning is given. |
1813 \item If possible the interface gets a member named $m$ that has the minimum
number of required parameters among all the members in the superinterfaces, the
maximal number of positionals, and the superset of named parameters. The typ
es of these are all \DYNAMIC{}. If this is impossible then no member $m$ appears
in the interface. | 1817 \item If possible the interface gets a member named $m$ that has the minimum
number of required parameters among all the members in the superinterfaces, the
maximal number of positionals, and the superset of named parameters. The typ
es of these are all \DYNAMIC{}. If this is impossible then no member $m$ appears
in the interface. |
1814 \end{itemize} (\ref{interfaceInheritanceAndOverriding}) | 1818 \end{itemize} (\ref{interfaceInheritanceAndOverriding}) |
1815 \item Rule \ref{typeSigAssignable} applies to interfaces as well as classes (\
ref{interfaceInheritanceAndOverriding}). | 1819 \item Rule \ref{typeSigAssignable} applies to interfaces as well as classes (\
ref{interfaceInheritanceAndOverriding}). |
1816 \item It is a static warning if a concrete class does not have an implementatio
n for a method in any of its superinterfaces unless it declares its own \cd{n
oSuchMethod} method (\ref{superinterfaces}). | 1820 \item It is a static warning if a concrete class does not have an implementatio
n for a method in any of its superinterfaces unless it has a \cd{noSuchMethod}
method (\ref{superinterfaces}). |
1817 \item The identifier of a named constructor cannot be the same as the name of a
member declared (as opposed to inherited) in the same class (\ref{constructors})
. | 1821 \item The identifier of a named constructor cannot be the same as the name of a
member declared (as opposed to inherited) in the same class (\ref{constructors})
. |
1818 \end{enumerate} | 1822 \end{enumerate} |
1819 } | 1823 } |
1820 | 1824 |
1821 | 1825 |
1822 %Can we have abstract getters and setters? | 1826 %Can we have abstract getters and setters? |
1823 | 1827 |
1824 \subsection{ Superinterfaces} | 1828 \subsection{ Superinterfaces} |
1825 \LMLabel{superinterfaces} | 1829 \LMLabel{superinterfaces} |
1826 % what about rules about classes that fail to implement their interfaces? | 1830 % what about rules about classes that fail to implement their interfaces? |
(...skipping 13 matching lines...) Expand all Loading... |
1840 It is a compile-time error if the superclass of a class $C$ is specified as a su
perinterface of $C$. | 1844 It is a compile-time error if the superclass of a class $C$ is specified as a su
perinterface of $C$. |
1841 | 1845 |
1842 \rationale{ | 1846 \rationale{ |
1843 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. | 1847 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. |
1844 } | 1848 } |
1845 | 1849 |
1846 \LMHash{} | 1850 \LMHash{} |
1847 It is a compile-time error if the interface of a class $C$ is a superinterface o
f itself. | 1851 It is a compile-time error if the interface of a class $C$ is a superinterface o
f itself. |
1848 | 1852 |
1849 \LMHash{} | 1853 \LMHash{} |
1850 Let $C$ be a concrete class that does not declare its own \code{noSuchMethod()}
method. | 1854 Let $C$ be a concrete class that does not have a \code{noSuchMethod()} method di
stinct from the one declared in class \cd{Object}. |
1851 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 non-abs
tract instance member $m$ of type $F'$ such that $F' <: F$. | 1855 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 non-abs
tract instance member $m$ of type $F'$ such that $F' <: F$. |
1852 | 1856 |
1853 \commentary{A class does not inherit members from its superinterfaces. However,
its implicit interface does. | 1857 \commentary{A class does not inherit members from its superinterfaces. However,
its implicit interface does. |
1854 } | 1858 } |
1855 | 1859 |
1856 | 1860 |
1857 \rationale { | 1861 \rationale { |
1858 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. | 1862 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. |
1859 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. | 1863 We also disable these warnings if a \code{noSuchMethod()} declaration is present
or inherited from any class other than \cd{Object}. In such cases, the supporte
d interface is going to be implemented via \code{noSuchMethod()} and no actual d
eclarations of the implemented interface's members are needed. This allows proxy
classes for specific types to be implemented without provoking type warnings. |
1860 | |
1861 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. If one does want to suppress the warnings in a subclass, one can def
ine a simple implementation of \code{noSuchMethod} in the subclass: | |
1862 } | 1864 } |
1863 | 1865 |
1864 \begin{dartCode} | |
1865 noSuchMethod(inv) =$>$ \SUPER.noSuchMethod(inv); | |
1866 \end{dartCode} | |
1867 | 1866 |
1868 \LMHash{} | 1867 \LMHash{} |
1869 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$. | 1868 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$. |
1870 | 1869 |
1871 \rationale{ | 1870 \rationale{ |
1872 However, if a class does explicitly declare a member that conflicts with its sup
erinterface, this always yields a static warning. | 1871 However, if a class does explicitly declare a member that conflicts with its sup
erinterface, this always yields a static warning. |
1873 | 1872 |
1874 } | 1873 } |
1875 %It is a static warning if an imported superinterface of a class $C$ declares pr
ivate members. | 1874 %It is a static warning if an imported superinterface of a class $C$ declares pr
ivate members. |
1876 | 1875 |
(...skipping 4943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6820 \rationale{ | 6819 \rationale{ |
6821 The naive reader might conclude that, since it is not legal to declare a functio
n with an empty optional parameter list, these rules are pointless. However, the
y induce useful relationships between function types that declare no optional p
arameters and those that do. | 6820 The naive reader might conclude that, since it is not legal to declare a functio
n with an empty optional parameter list, these rules are pointless. However, the
y induce useful relationships between function types that declare no optional p
arameters and those that do. |
6822 } | 6821 } |
6823 | 6822 |
6824 \LMHash{} | 6823 \LMHash{} |
6825 A function type $T$ may be assigned to a function type $S$, written $T \Longlef
trightarrow S$, iff $T <: S$. | 6824 A function type $T$ may be assigned to a function type $S$, written $T \Longlef
trightarrow S$, iff $T <: S$. |
6826 | 6825 |
6827 \LMHash{} | 6826 \LMHash{} |
6828 % ensure that Object and dynamic may be assign dot a function type | 6827 % ensure that Object and dynamic may be assign dot a function type |
6829 A function is always an instance of some class that implements the class \code{F
unction} and implements a \CALL{} method with the same signature as the function
. All function types are subtypes of \code{Function}. | 6828 A function is always an instance of some class that implements the class \code{F
unction} and implements a \CALL{} method with the same signature as the function
. All function types are subtypes of \code{Function}. |
6830 If a type $I$ includes an instance method named \CALL{}, and the type of \CALL{}
is the function type $F$, then $I$ is considered to be more specific than $F$.
It is a static warning if a concrete class implements \cd{Function} and does no
t have a concrete method named \CALL{} unless that class declares its own implem
entation of \cd{noSuchMethod()}. | 6829 If a type $I$ includes an instance method named \CALL{}, and the type of \CALL{}
is the function type $F$, then $I$ is considered to be more specific than $F$.
It is a static warning if a concrete class implements \cd{Function} and does no
t have a concrete method named \CALL{} unless that class has an implementation o
f \cd{noSuchMethod()} distinct from the one declared in class \cd{Object}. |
6831 | 6830 |
6832 | 6831 |
6833 | 6832 |
6834 | 6833 |
6835 %\commentary{Need to specify how a function values dynamic type is derived from
its static signature.} | 6834 %\commentary{Need to specify how a function values dynamic type is derived from
its static signature.} |
6836 | 6835 |
6837 \LMHash{} | 6836 \LMHash{} |
6838 A function type $(T_1, \ldots T_{k}, [T_{k+1} \ldots, T_{n+m}]) \rightarrow T$
is a more specific than the | 6837 A function type $(T_1, \ldots T_{k}, [T_{k+1} \ldots, T_{n+m}]) \rightarrow T$
is a more specific than the |
6839 function type $(S_1, \ldots, S_{k+j}, [S_{k+j+1} \ldots, S_{n}]) \rightarrow S$,
if all of the following conditions are met: | 6838 function type $(S_1, \ldots, S_{k+j}, [S_{k+j+1} \ldots, S_{n}]) \rightarrow S$,
if all of the following conditions are met: |
6840 \begin{enumerate} | 6839 \begin{enumerate} |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7338 | 7337 |
7339 The invariant that each normative paragraph is associated with a line | 7338 The invariant that each normative paragraph is associated with a line |
7340 containing the text \LMHash{} should be maintained. Extra occurrences | 7339 containing the text \LMHash{} should be maintained. Extra occurrences |
7341 of \LMHash{} can be added if needed, e.g., in order to make | 7340 of \LMHash{} can be added if needed, e.g., in order to make |
7342 individual \item{}s in itemized lists addressable. Each \LM.. command | 7341 individual \item{}s in itemized lists addressable. Each \LM.. command |
7343 must occur on a separate line. \LMHash{} must occur immediately | 7342 must occur on a separate line. \LMHash{} must occur immediately |
7344 before the associated paragraph, and \LMLabel must occur immediately | 7343 before the associated paragraph, and \LMLabel must occur immediately |
7345 after the associated \section{}, \subsection{} etc. | 7344 after the associated \section{}, \subsection{} etc. |
7346 | 7345 |
7347 ---------------------------------------------------------------------- | 7346 ---------------------------------------------------------------------- |
OLD | NEW |