Skip to main content Accessibility help
×
Hostname: page-component-5b777bbd6c-pf7kn Total loading time: 0 Render date: 2025-06-25T18:43:58.924Z Has data issue: false hasContentIssue false

7 - Subtyping

Published online by Cambridge University Press:  29 May 2025

Davide Sangiorgi
Affiliation:
Institut National de Recherche en Informatique et en Automatique (INRIA), Rocquencourt
David Walker
Affiliation:
University of Oxford
Get access

Summary

Subtyping is a preorder on types that can be thought of as inclusion between the sets of the values of the types. If S is a subtype of T then a value of type S is a also a value of type T. For instance if Nat, Int, and Real are the types of natural numbers, integers and reals, respectively, then we could naturally stipulate that Nat is a subtype of Int and that Int is a subtype of Real.

If S is a subtype of T then an expression of type S can always replace an expression of type T; if the program before the replacement is well typed, then also the program after the replacement will be so. This is so because the operations available on values of type T - both the pre-defined and the user-defined operations - are also available on values of type S. For instance, operations such as multiplication and division that are available on Real are also available on Int. The converse, by contrast, may be false; for instance on Int there are operations like successor and predecessor that do not make sense on Real. The possibility of having operations that work on all subtypes of a given type is a major advantage of subtyping in a programming language. (In the implementation of programming languages, the subtyping from integers to reals requires a conversion that modifies the representation of a number; therefore operations defined on both types will have different implementations for the two types. Due to this non-uniformity, the subtyping between integers and reals is called ‘ad hoc’ subtyping. In general, all subtyping between basic types is ad hoc. The subtyping on structured types - the non-basic types - that will be presented in this section is, by contrast, uniform.)

Programming language constructs that are usually associated with subtyping are records, variants, and objects. Subtyping is a key feature of object-oriented languages (perhaps the key feature). Indeed, the study of subtyping and of the associated programming constructs has been motivated mainly by the interest in object-oriented languages.

Type
Chapter
Information
The Pi-Calculus
A Theory of Mobile Processes
, pp. 260 - 280
Publisher: Cambridge University Press
Print publication year: 2001

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Book purchase

Temporarily unavailable

Save book to Kindle

To save this book to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Subtyping
  • Davide Sangiorgi, Institut National de Recherche en Informatique et en Automatique (INRIA), Rocquencourt, David Walker, University of Oxford
  • Book: The Pi-Calculus
  • Online publication: 29 May 2025
  • Chapter DOI: https://doi.org/10.1017/9781316134924.015
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Subtyping
  • Davide Sangiorgi, Institut National de Recherche en Informatique et en Automatique (INRIA), Rocquencourt, David Walker, University of Oxford
  • Book: The Pi-Calculus
  • Online publication: 29 May 2025
  • Chapter DOI: https://doi.org/10.1017/9781316134924.015
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Subtyping
  • Davide Sangiorgi, Institut National de Recherche en Informatique et en Automatique (INRIA), Rocquencourt, David Walker, University of Oxford
  • Book: The Pi-Calculus
  • Online publication: 29 May 2025
  • Chapter DOI: https://doi.org/10.1017/9781316134924.015
Available formats
×