Skip to content

Commit 7a57a81

Browse files
committed
Reorganized material on null/Null
1 parent 87084d8 commit 7a57a81

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

specification/dartLangSpec.tex

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3254,13 +3254,13 @@ \subsubsection{The Operator `=='}
32543254
if the dynamic type of $o$ is a class $C$,
32553255
and $C$ has a primitive operator \lit{==}.
32563256
\item The class \code{Object} has a primitive operator \lit{==}.
3257+
\item The class \code{Null} has a primitive operator \lit{==}.
32573258
\item A class $C$ has a primitive operator \lit{==}
32583259
if it does not have an implementation of the operator \lit{==}
32593260
that overrides the one inherited from \code{Object}.
32603261
\commentary{%
32613262
In particular, the following have a primitive operator \lit{==}:
3262-
The null object (\ref{null}),
3263-
function objects obtained by function closurization of
3263+
Function objects obtained by function closurization of
32643264
a static method or a top-level function
32653265
(\ref{functionClosurization}),
32663266
instances of type \code{bool}
@@ -8669,20 +8669,8 @@ \subsection{Null}
86698669
\end{grammar}
86708670

86718671
\LMHash{}%
8672-
The null object is the sole instance of the built-in class \code{Null}.
8673-
% The following can be a consequence of the declaration of `Null`,
8674-
% but we don't spell that out, we just require that it is an error.
8675-
Attempting to instantiate \code{Null} causes a compile-time error.
8676-
It is a compile-time error for a class to extend, mix in or implement
8677-
\code{Null}.
8678-
The \code{Null} class extends the \code{Object} class
8679-
and declares no methods except those also declared by \code{Object}.
8680-
In particular, the \code{Null} class does not override the \lit{==} operator
8681-
inherited from the \code{Object} class.
8682-
8683-
\LMHash{}%
8684-
The static type of \NULL{} is the \code{Null} type.
8685-
8672+
The static type of \NULL{} is the \code{Null} type
8673+
(\ref{typeNull}).
86868674

86878675
\subsection{Numbers}
86888676
\LMLabel{numbers}
@@ -21383,7 +21371,7 @@ \subsection{Type \code{Never}}
2138321371

2138421372
\LMHash{}%
2138521373
The Dart core library \code{dart:core} exports a type named \code{Never}.
21386-
No object has dynamic type \code{Never}.
21374+
No object has a dynamic type which is \code{Never} or a subtype thereof.
2138721375

2138821376
\commentary{%
2138921377
In other words, \code{Never} is the empty type.
@@ -21410,24 +21398,40 @@ \subsection{Type \code{Null}}
2141021398
\LMLabel{typeNull}
2141121399

2141221400
\LMHash{}%
21413-
The Dart core library \code{dart:core} exports a type named \code{Null},
21401+
The Dart core library \code{dart:core} exports a type named \code{Null}.
2141421402
There is exactly one object whose dynamic type is \code{Null},
21415-
and that is the null object.
21403+
and that is the null object
21404+
(\ref{null}).
2141621405

2141721406
\commentary{%
2141821407
In other words, \code{Null} is a singleton type.
21419-
\code{Null} is a subtype of all other types
21420-
other than \code{Never} and any type which is
21421-
a subtype of \code{Never}
21408+
Apart from top types
21409+
(\ref{superBoundedTypes}),
21410+
\code{Null} is a subtype of all types of the form \code{$T$?},
21411+
and of all types $S$ such that \futureOrBase{S} is one of the above.
21412+
The only non-trivial subtypes of \code{Null} are
21413+
\code{Never} and subtypes of \code{Never}
2142221414
(\ref{subtypeRules}).%
2142321415
}
2142421416

21417+
\LMHash{}%
21418+
Attempting to instantiate \code{Null} causes a compile-time error.
21419+
It is a compile-time error for a class to extend, mix in or implement
21420+
\code{Null}.
21421+
The \code{Null} class declares exactly the same members
21422+
with the same signatures as the class \code{Object}.
21423+
21424+
\commentary{%
21425+
The \code{Null} class has a primitive \lit{==} operator
21426+
(\ref{theOperatorEqualsEquals}).%
21427+
}
21428+
2142521429
\rationale{%
2142621430
\code{Null} is mainly used implicitly in
2142721431
a type of the form \code{$T$?} for some $T$.
2142821432
If $e$ is an expression of type \code{$T$?} that evaluates to an object $o$,
2142921433
then $o$ can be an instance of a subtype of $T$,
21430-
or it could be the null object.
21434+
or it can be the null object.
2143121435
The latter situation is commonly interpreted to mean that
2143221436
the computation did not yield a result.
2143321437
In this sense, \code{Null} can be considered to model

0 commit comments

Comments
 (0)