Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-n9wrp Total loading time: 0 Render date: 2024-07-22T13:39:21.014Z Has data issue: false hasContentIssue false

16 - Subtypes and Intersection Types

Published online by Cambridge University Press:  28 January 2010

John C. Reynolds
Affiliation:
Carnegie Mellon University, Pennsylvania
Get access

Summary

Many programming languages provide a variety of implicit conversions (sometimes called “coercions”) that serve to make programs more succinct; the most widespread example is the conversion of integers to real (floating-point) numbers. In modern type systems, such conversions are captured by the concept of subtyping.

In this chapter, we extend the simple type system by introducing a subtype relation ≤ between types. When θ ≤ θ′, we say that θ is a subtype of θ′ or, occasionally, that θ′ is a supertype of θ. Syntactically, this relationship implies that any expression of type θ is also an expression of type θ′, and thus can be used in any context that permits an expression of type θ′. In extrinsic semantics, the relationship implies that the set denoted by θ is a subset of that denoted by θ′, and that values which are equivalent for the type θ are also equivalent for θ′; more simply, the partial equivalence relation for θ must be a subset of the partial equivalence relation for θ′. In intrinsic semantics, θ ≤ θ′ implies that there is an implicit conversion function from the meaning of θ to the meaning of θ′.

We will also introduce intersection types, which permit the description of values with more than one conventional type. In extrinsic semantics, the intersection of types is modelled by the intersection of partial equivalence relations, and in intrinsic semantics by a constrained product.

We will find that both extrinsic and intrinsic semantics clarify the subtle interactions between subtypes and generic operators.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 1998

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.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@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.

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.

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.

Available formats
×