Hostname: page-component-89b8bd64d-r6c6k Total loading time: 0 Render date: 2026-05-07T03:57:42.043Z Has data issue: false hasContentIssue false

A simple blame calculus for explicit nulls

Published online by Cambridge University Press:  27 December 2024

ONDŘEJ LHOTÁK
Affiliation:
University of Waterloo, Waterloo, Canada (e-mail: olhotak@uwaterloo.ca)
PHILIP WADLER
Affiliation:
School of Informatics, University of Edinburgh, Edinburgh, UK (e-mail: wadler@inf.ed.ac.uk)
Rights & Permissions [Opens in a new window]

Abstract

Gradual typing provides a model for when a legacy language with less precise types interacts with a newer language with more precise types. Casts mediate between types of different precision, allocating blame when a value fails to conform to a type. The blame theorem asserts that blame always falls on the less-precisely typed side of a cast. One instance of interest is when a legacy language (such as Java) permits null values at every type, while a newer language (such as Scala or Kotlin) explicitly indicates which types permit null values. Nieto et al. in 2020 introduced a gradually typed calculus for just this purpose. The calculus requires three distinct constructors for function types and a non-standard proof of the blame theorem; it can embed terms from the legacy language into the newer language (or vice versa) only when they are closed. Here, we define a simpler calculus that is more orthogonal, with one constructor for function types and one for possibly nullable types, and with an entirely standard proof of the blame theorem; it can embed terms from the legacy language into the newer language (and vice versa) even if they are open. All results in the paper have been mechanized in Coq.

Information

Type
Research Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2025. Published by Cambridge University Press
Figure 0

Fig. 1. syntax.

Figure 1

Fig. 2. typing rules.

Figure 2

Fig. 3. reduction rules.

Figure 3

Fig. 4. subtyping rules.

Figure 4

Fig. 5. Definition of safe terms.

Figure 5

Fig. 6. syntax.

Figure 6

Fig. 7. typing rules.

Figure 7

Fig. 8. Translation from to

Figure 8

Fig. 9. Syntax of and contexts.

Figure 9

Fig. 10. context typing rules.

Figure 10

Fig. 11. context typing rules.

Supplementary material: File

Lhoták and Wadler supplementary material

Lhoták and Wadler supplementary material

Download Lhoták and Wadler supplementary material(File)
File 84.8 KB
Submit a response

Discussions

No Discussions have been published for this article.