In programming language theory, subtyping (also called subtype polymorphism or inclusion polymorphism) is a form of type polymorphism. A subtype is a datatype that is related to another datatype (the supertype) by some notion of substitutability, meaning that program elements (typically subroutines or functions), written to operate on elements of the supertype, can also operate on elements of the subtype.
If S is a subtype of T, the subtyping relation (written as S <: T, S ⊑ T,[1] or S ≤: T ) means that any term of type S can safely be used in any context where a term of type T is expected. The precise semantics of subtyping here crucially depends on the particulars of how "safely be used" and "any context" are defined by a given type formalism or programming language. The type system of a programming language essentially defines its own subtyping relation, which may well be trivial, should the language support no (or very little) conversion mechanisms.
Due to the subtyping relation, a term may belong to more than one type. Subtyping is therefore a form of type polymorphism. In object-oriented programming the term 'polymorphism' is commonly used to refer solely to this subtype polymorphism, while the techniques of parametric polymorphism would be considered generic programming.
Functional programming languages often allow the subtyping of records. Consequently, simply typed lambda calculus extended with record types is perhaps the simplest theoretical setting in which a useful notion of subtyping may be defined and studied.[2] Because the resulting calculus allows terms to have more than one type, it is no longer a "simple" type theory. Since functional programming languages, by definition, support function literals, which can also be stored in records, records types with subtyping provide some of the features of object-oriented programming. Typically, functional programming languages also provide some, usually restricted, form of parametric polymorphism. In a theoretical setting, it is desirable to study the interaction of the two features; a common theoretical setting is system F<:. Various calculi that attempt to capture the theoretical properties of object-oriented programming may be derived from system F<:.
The concept of subtyping is related to the linguistic notions of hyponymy and holonymy. It is also related to the concept of bounded quantification in mathematical logic (see Order-sorted logic). Subtyping should not be confused with the notion of (class or object) inheritance from object-oriented languages;[3] subtyping is a relation between types (interfaces in object-oriented parlance) whereas inheritance is a relation between implementations stemming from a language feature that allows new objects to be created from existing ones. In a number of object-oriented languages, subtyping is called interface inheritance, with inheritance referred to as implementation inheritance.
^Cardelli, Luca. A semantics of multiple inheritance. In G. Kahn, D. MacQueen, and G. Plotkin, editors, Semantics of Data Types, volume 173 of Lecture Notes in Computer Science, pages 51–67. Springer-Verlag, 1984. Full version in Information and Computation, 76(2/3):138–164, 1988.
its own subtyping relation, which may well be trivial, should the language support no (or very little) conversion mechanisms. Due to the subtyping relation...
The subtypes of HIV include two main subtypes, known as HIV type 1 (HIV-1) and HIV type 2 (HIV-2). These subtypes have distinct genetic differences and...
Look up subtype in Wiktionary, the free dictionary. Subtype may refer to: Viral subtypes, such as Subtypes of HIV Subtyping, a form of type polymorphism...
principle (LSP) is a particular definition of a subtyping relation, called strong behavioral subtyping, that was initially introduced by Barbara Liskov...
In object-oriented programming, behavioral subtyping is the principle that subclasses should satisfy the expectations of clients accessing subclass objects...
type, which is invoked implicitly. Structural subtyping is arguably more flexible than nominative subtyping, as it permits the creation of ad hoc types...
definition, the subtyping scheme only takes into account the two outer proteins, not the at least 8 proteins internal to the virus. Using subtyping and host...
isomorphic to an existing type. In a similar fashion, nominal subtyping means that one type is a subtype of another if and only if it is explicitly declared to...
the subtype hierarchy. However, because subtyping is transitive, that results in every type becoming related to every other type, and so subtyping would...
In virology, influenza A virus subtype H1N1 (A/H1N1) is a subtype of influenza A virus. Major outbreaks of H1N1 strains in humans include the 1918 Spanish...
type" which he considered to be distinct from Caucasians, rather than a subtype of it as others had done. While Blumenbach had erroneously thought that...
at compile time, it is not a substitute for late binding as found in subtyping polymorphism. The previous section notwithstanding, there are other ways...
implementation Bounded quantification, restricts type parameters to a range of subtypesSubtyping, different classes related by some common superclass can be used in...
principle, which applies these ideas to object-oriented programming, subtyping, and inheritance. Her work was recognized with the 2008 Turing Award,...
Influenza A virus subtype H5N1 (A/H5N1) is a subtype of the influenza A virus, which causes influenza (flu), predominantly in birds. It is enzootic (maintained...
personality types is understood as having three "instinctual subtypes". These subtypes are believed to be formed according to which one of three instinctual...
Endemism is the state of a species only being found in a single defined geographic location, such as an island, state, nation, country or other defined...
as a term's declared or inferred type (or base type in a language with subtyping) is used to determine which of several possibilities will be used at a...
A music genre is a conventional category (i.e, genre) that identifies some pieces of music as belonging to a shared tradition or set of conventions. Genre...
in question must not be semi-arid or arid. The cooler Dfb, Dwb, and Dsb subtypes are also known as hemiboreal climates. Although amount of snowfall is not...
with subtyping), and has problems such as: Checking that the type system admits transitivity of subtyping. Checking the transitivity of subtyping in the...
The transient receptor potential cation channel subfamily V member 1 (TRPV1), also known as the capsaicin receptor and the vanilloid receptor 1, is a protein...
subtypes, which vary in geographical prevalence. HIV subtype (clade) B, for example is predominant in Europe, the Americas and Japan, whereas subtype...