Today I Learned

Some of the things I've learned every day since Oct 10, 2016

93: Subtypes (Programming)

Let A, B be data types in the type system of a programming language. To say that A is a subtype of B, often written A < : B, means that objects of type A can be used where objects of type B are expected. That is, A is a more specific version of B in some sense. (Equivalently, B is said to be a supertype of A.)

Subtyping forms a reflexive and transitive relation on a given set of types.

An (non-technical) example would be P < : F < : B, where P is the type of penguins, F is that of flightless birds, and B is that of birds. A penguin is acceptable where a bird or even a flightless bird is expected, but conversely not any bird will do when a penguin is expected.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: