Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: docs/language/dartLangSpec.tex

Issue 2641873003: Make it more explicit that `Null` doesn't extend anything but `Object`. (Closed)
Patch Set: Without the dart.sty fix Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 \\
(...skipping 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 %\Q{Any methods, such as \code{isNull}?} 2624 %\Q{Any methods, such as \code{isNull}?}
2625 2625
2626 \begin{grammar} 2626 \begin{grammar}
2627 {\bf nullLiteral:} 2627 {\bf nullLiteral:}
2628 \NULL{} 2628 \NULL{}
2629 . 2629 .
2630 \end{grammar} 2630 \end{grammar}
2631 2631
2632 \LMHash{} 2632 \LMHash{}
2633 The null object is the sole instance of the built-in class \code{Null}. Attempti ng to instantiate \code{Null} causes a run-time error. It is a compile-time erro r for a class to extend, mix in or implement \code{Null}. 2633 The null object is the sole instance of the built-in class \code{Null}. Attempti ng to instantiate \code{Null} causes a run-time error. It is a compile-time erro r for a class to extend, mix in or implement \code{Null}.
2634 The \code{Null} class declares no methods except those also declared by \code{Ob ject}. 2634 The \code{Null} class extends the \code{Object} class and declares no methods ex cept those also declared by \code{Object}.
2635 2635
2636 \LMHash{} 2636 \LMHash{}
2637 The static type of \NULL{} is the \code{Null} type. 2637 The static type of \NULL{} is the \code{Null} type.
2638 2638
2639 2639
2640 \subsection{Numbers} 2640 \subsection{Numbers}
2641 \LMLabel{numbers} 2641 \LMLabel{numbers}
2642 2642
2643 \LMHash{} 2643 \LMHash{}
2644 A {\em numeric literal} is either a decimal or hexadecimal integer of arbitrary size, or a decimal double. 2644 A {\em numeric literal} is either a decimal or hexadecimal integer of arbitrary size, or a decimal double.
(...skipping 4752 matching lines...) Expand 10 before | Expand all | Expand 10 after
7397 \end{itemize} 7397 \end{itemize}
7398 7398
7399 %\Q{Can wacky stuff happen with interface injection, e.g., a direct superinterfa ce becomes indirect? What about side effects - loading order can affect type rel ationships. 7399 %\Q{Can wacky stuff happen with interface injection, e.g., a direct superinterfa ce becomes indirect? What about side effects - loading order can affect type rel ationships.
7400 %} 7400 %}
7401 7401
7402 \LMHash{} 7402 \LMHash{}
7403 A type $T$ is more specific than a type $S$, written $T << S$, if one of the fo llowing conditions is met: 7403 A type $T$ is more specific than a type $S$, written $T << S$, if one of the fo llowing conditions is met:
7404 \begin{itemize} 7404 \begin{itemize}
7405 \item $T$ is $S$. 7405 \item $T$ is $S$.
7406 \item $T$ is $\bot$. 7406 \item $T$ is $\bot$.
7407 \item $T$ is \NULL{} and $S$ is not $\bot$. 7407 \item $T$ is \code{Null} and $S$ is not $\bot$.
7408 \item $S$ is \DYNAMIC{}. 7408 \item $S$ is \DYNAMIC{}.
7409 \item $S$ is a direct supertype of $T$. 7409 \item $S$ is a direct supertype of $T$.
7410 \item $T$ is a type parameter and $S$ is the upper bound of $T$. 7410 \item $T$ is a type parameter and $S$ is the upper bound of $T$.
7411 \item $T$ is a type parameter and $S$ is \cd{Object}. 7411 \item $T$ is a type parameter and $S$ is \cd{Object}.
7412 \item $T$ is of the form $I<T_1, \ldots, T_n>$ and $S$ is of the form $I<S_1, \l dots, S_n>$ and: 7412 \item $T$ is of the form $I<T_1, \ldots, T_n>$ and $S$ is of the form $I<S_1, \l dots, S_n>$ and:
7413 $T_i << S_i, 1 \le i \le n$ 7413 $T_i << S_i, 1 \le i \le n$
7414 \item $T$ and $S$ are both function types, and $T << S$ under the rules of secti on \ref{functionTypes}. 7414 \item $T$ and $S$ are both function types, and $T << S$ under the rules of secti on \ref{functionTypes}.
7415 \item $T$ is a function type and $S$ is \cd{Function}. 7415 \item $T$ is a function type and $S$ is \cd{Function}.
7416 \item $T << U$ and $U << S$. 7416 \item $T << U$ and $U << S$.
7417 \end{itemize} 7417 \end{itemize}
7418 7418
7419 \LMHash{} 7419 \LMHash{}
7420 $<<$ is a partial order on types. 7420 $<<$ is a partial order on types.
7421 $T$ is a subtype of $S$, written $T <: S$, iff $[\bot/\DYNAMIC{}]T << S$. 7421 $T$ is a subtype of $S$, written $T <: S$, iff $[\bot/\DYNAMIC{}]T << S$.
7422 7422
7423 \rationale{ 7423 \rationale{
7424 Note that $<:$ is not a partial order on types, it is only binary relation on ty pes. This is because $<:$ is not transitive. If it was, the subtype rule would h ave a cycle. For example: 7424 Note that $<:$ is not a partial order on types, it is only binary relation on ty pes. This is because $<:$ is not transitive. If it was, the subtype rule would h ave a cycle. For example:
7425 $List <: List<String>$ and $List<int> <: List$, but $List<int>$ is not a subtype of $List<String>$. 7425 $List <: List<String>$ and $List<int> <: List$, but $List<int>$ is not a subtype of $List<String>$.
7426 Although $<:$ is not a partial order on types, it does contain a partial order, namely $<<$. This means that, barring raw types, intuition about classical subty pe rules does apply. 7426 Although $<:$ is not a partial order on types, it does contain a partial order, namely $<<$. This means that, barring raw types, intuition about classical subty pe rules does apply.
7427 } 7427 }
7428 7428
7429 \commentary{
7430 The \code{Null} type is more specific than all non-$\bot$ types, even though
7431 it doesn't actually extend or implement those types.
7432 The other types are effectively treated as if they are {\em nullable},
7433 which makes \NULL{} assignable to them.
7434 }
7435
7429 \LMHash{} 7436 \LMHash{}
7430 $S$ is a supertype of $T$, written $S :> T$, iff $T$ is a subtype of $S$. 7437 $S$ is a supertype of $T$, written $S :> T$, iff $T$ is a subtype of $S$.
7431 7438
7432 \commentary{The supertypes of an interface are its direct supertypes and their s upertypes. } 7439 \commentary{The supertypes of an interface are its direct supertypes and their s upertypes. }
7433 7440
7434 \LMHash{} 7441 \LMHash{}
7435 An interface type $T$ may be assigned to a type $S$, written $T \Longleftrighta rrow S$, iff either $T <: S$, $S <: T$, or either $T$ or $S$ is the \code{Null} type. 7442 An interface type $T$ may be assigned to a type $S$, written $T \Longleftrighta rrow S$, iff either $T <: S$, $S <: T$.
7436 7443
7437 \rationale{This rule may surprise readers accustomed to conventional typecheckin g. The intent of the $\Longleftrightarrow$ relation is not to ensure that an ass ignment is correct. Instead, it aims to only flag assignments that are almost ce rtain to be erroneous, without precluding assignments that may work. 7444 \rationale{This rule may surprise readers accustomed to conventional typecheckin g. The intent of the $\Longleftrightarrow$ relation is not to ensure that an ass ignment is correct. Instead, it aims to only flag assignments that are almost ce rtain to be erroneous, without precluding assignments that may work.
7438 7445
7439 For example, assigning a value of static type Object to a variable with static t ype String, while not guaranteed to be correct, might be fine if the runtime val ue happens to be a string. 7446 For example, assigning a value of static type Object to a variable with static t ype String, while not guaranteed to be correct, might be fine if the runtime val ue happens to be a string.
7440 } 7447 }
7441 7448
7442 \subsection{Function Types} 7449 \subsection{Function Types}
7443 \LMLabel{functionTypes} 7450 \LMLabel{functionTypes}
7444 7451
7445 \LMHash{} 7452 \LMHash{}
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
8033 8040
8034 The invariant that each normative paragraph is associated with a line 8041 The invariant that each normative paragraph is associated with a line
8035 containing the text \LMHash{} should be maintained. Extra occurrences 8042 containing the text \LMHash{} should be maintained. Extra occurrences
8036 of \LMHash{} can be added if needed, e.g., in order to make 8043 of \LMHash{} can be added if needed, e.g., in order to make
8037 individual \item{}s in itemized lists addressable. Each \LM.. command 8044 individual \item{}s in itemized lists addressable. Each \LM.. command
8038 must occur on a separate line. \LMHash{} must occur immediately 8045 must occur on a separate line. \LMHash{} must occur immediately
8039 before the associated paragraph, and \LMLabel must occur immediately 8046 before the associated paragraph, and \LMLabel must occur immediately
8040 after the associated \section{}, \subsection{} etc. 8047 after the associated \section{}, \subsection{} etc.
8041 8048
8042 ---------------------------------------------------------------------- 8049 ----------------------------------------------------------------------
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698