In
programming language theory,
subtyping (also
subtype polymorphism or
inclusion polymorphism) is a form of
type polymorphism in which 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 is often written S <: T, to mean that any term of type S can be
safely used in a context where a term of type T is expected. The precise semantics of subtyping crucially depends on the particulars of what "safely used in a context where" means in a given
programming language. The
type system of a programming language essentially defines its own subtyping relation, which may well be
trivial.