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

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

Issue 2555343004: Make Null act like the bottom type for all the (default nullable) types. (Closed)
Patch Set: Created 4 years 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 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 {\bf nullLiteral:} 2609 {\bf nullLiteral:}
2610 \NULL{} 2610 \NULL{}
2611 . 2611 .
2612 \end{grammar} 2612 \end{grammar}
2613 2613
2614 \LMHash{} 2614 \LMHash{}
2615 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}. 2615 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}.
2616 The \code{Null} class declares no methods except those also declared by \code{Ob ject}. 2616 The \code{Null} class declares no methods except those also declared by \code{Ob ject}.
2617 2617
2618 \LMHash{} 2618 \LMHash{}
2619 The static type of \NULL{} is $\bot$. 2619 The static type of \NULL{} is the \code{Null} type.
2620 2620
2621 \rationale{The decision to use $\bot$ instead of \code{Null} allows \NULL{} to b e be assigned everywhere without complaint by the static checker. 2621 \rationale{
2622 The \code{Null} type can be assigned anywhere without complaint by the static ch ecker.
karlklose 2016/12/09 08:03:55 Can you be more precise about what being assigned
Lasse Reichstein Nielsen 2016/12/09 10:32:44 Hmm, not really. I think I'll just remove the enti
2622 } 2623 }
2623 2624
2624 2625
2625 \subsection{Numbers} 2626 \subsection{Numbers}
2626 \LMLabel{numbers} 2627 \LMLabel{numbers}
2627 2628
2628 \LMHash{} 2629 \LMHash{}
2629 A {\em numeric literal} is either a decimal or hexadecimal integer of arbitrary size, or a decimal double. 2630 A {\em numeric literal} is either a decimal or hexadecimal integer of arbitrary size, or a decimal double.
2630 2631
2631 \begin{grammar} 2632 \begin{grammar}
(...skipping 4730 matching lines...) Expand 10 before | Expand all | Expand 10 after
7362 \item 7363 \item
7363 If $I$ is listed in the \EXTENDS{} clause of $J$% or an interface injection decl aration has extended $J$ with $I$ 7364 If $I$ is listed in the \EXTENDS{} clause of $J$% or an interface injection decl aration has extended $J$ with $I$
7364 . 7365 .
7365 \item If $I$ is listed in the \IMPLEMENTS{} clause of $J$ 7366 \item If $I$ is listed in the \IMPLEMENTS{} clause of $J$
7366 7367
7367 \item If $I$ is listed in the \WITH{} clause of $J$ 7368 \item If $I$ is listed in the \WITH{} clause of $J$
7368 7369
7369 \item If $J$ is a mixin application (\ref{mixinApplication}) of the mixin of $I$ . 7370 \item If $J$ is a mixin application (\ref{mixinApplication}) of the mixin of $I$ .
7370 \end{itemize} 7371 \end{itemize}
7371 7372
7372 \commentary{
7373
7374
7375 }
7376
7377 %\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. 7373 %\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.
7378 %} 7374 %}
7379 7375
7380 \LMHash{} 7376 \LMHash{}
7381 A type $T$ is more specific than a type $S$, written $T << S$, if one of the fo llowing conditions is met: 7377 A type $T$ is more specific than a type $S$, written $T << S$, if one of the fo llowing conditions is met:
7382 \begin{itemize} 7378 \begin{itemize}
7383 \item $T$ is $S$. 7379 \item $T$ is $S$.
7384 \item T is $\bot$. 7380 \item T is $\bot$.
7381 \item T id \NULL{} and $S$ is not $\bot$.
karlklose 2016/12/09 08:03:55 'id' -> 'is'
Lasse Reichstein Nielsen 2016/12/09 10:32:44 Done.
7385 \item S is \DYNAMIC{}. 7382 \item S is \DYNAMIC{}.
7386 \item $S$ is a direct supertype of $T$. 7383 \item $S$ is a direct supertype of $T$.
7387 \item $T$ is a type parameter and $S$ is the upper bound of $T$. 7384 \item $T$ is a type parameter and $S$ is the upper bound of $T$.
7388 \item $T$ is a type parameter and $S$ is \cd{Object}. 7385 \item $T$ is a type parameter and $S$ is \cd{Object}.
7389 \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: 7386 \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:
7390 $T_i << S_i, 1 \le i \le n$ 7387 $T_i << S_i, 1 \le i \le n$
7391 \item $T$ and $S$ are both function types, and $T << S$ under the rules of secti on \ref{functionTypes}. 7388 \item $T$ and $S$ are both function types, and $T << S$ under the rules of secti on \ref{functionTypes}.
7392 \item $T$ is a function type and $S$ is \cd{Function}. 7389 \item $T$ is a function type and $S$ is \cd{Function}.
7393 \item $T << U$ and $U << S$. 7390 \item $T << U$ and $U << S$.
7394 \end{itemize} 7391 \end{itemize}
7395 7392
7396 \LMHash{} 7393 \LMHash{}
7397 $<<$ is a partial order on types. 7394 $<<$ is a partial order on types.
7398 $T$ is a subtype of $S$, written $T <: S$, iff $[\bot/\DYNAMIC{}]T << S$. 7395 $T$ is a subtype of $S$, written $T <: S$, iff $[\bot/\DYNAMIC{}]T << S$.
7399 7396
7400 \rationale{ 7397 \rationale{
7401 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: 7398 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:
7402 $List <: List<String>$ and $List<int> <: List$, but $List<int>$ is not a subtype of $List<String>$. 7399 $List <: List<String>$ and $List<int> <: List$, but $List<int>$ is not a subtype of $List<String>$.
7403 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. 7400 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.
7404 } 7401 }
7405 7402
7406 \LMHash{} 7403 \LMHash{}
7407 $S$ is a supertype of $T$, written $S :> T$, iff $T$ is a subtype of $S$. 7404 $S$ is a supertype of $T$, written $S :> T$, iff $T$ is a subtype of $S$.
7408 7405
7409 \commentary{The supertypes of an interface are its direct supertypes and their s upertypes. } 7406 \commentary{The supertypes of an interface are its direct supertypes and their s upertypes. }
7410 7407
7411 \LMHash{} 7408 \LMHash{}
7412 An interface type $T$ may be assigned to a type $S$, written $T \Longleftrighta rrow S$, iff either $T <: S$ or $S <: T$. 7409 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.
7413 7410
7414 \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. 7411 \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.
7415 7412
7416 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. 7413 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.
7417 } 7414 }
7418 7415
7419 \subsection{Function Types} 7416 \subsection{Function Types}
7420 \LMLabel{functionTypes} 7417 \LMLabel{functionTypes}
7421 7418
7422 \LMHash{} 7419 \LMHash{}
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
8010 8007
8011 The invariant that each normative paragraph is associated with a line 8008 The invariant that each normative paragraph is associated with a line
8012 containing the text \LMHash{} should be maintained. Extra occurrences 8009 containing the text \LMHash{} should be maintained. Extra occurrences
8013 of \LMHash{} can be added if needed, e.g., in order to make 8010 of \LMHash{} can be added if needed, e.g., in order to make
8014 individual \item{}s in itemized lists addressable. Each \LM.. command 8011 individual \item{}s in itemized lists addressable. Each \LM.. command
8015 must occur on a separate line. \LMHash{} must occur immediately 8012 must occur on a separate line. \LMHash{} must occur immediately
8016 before the associated paragraph, and \LMLabel must occur immediately 8013 before the associated paragraph, and \LMLabel must occur immediately
8017 after the associated \section{}, \subsection{} etc. 8014 after the associated \section{}, \subsection{} etc.
8018 8015
8019 ---------------------------------------------------------------------- 8016 ----------------------------------------------------------------------
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