It is also related to the concept of bounded quantification in mathematical logic (see Order-sorted logic). The concept of subtyping is related to the linguistic notions of hyponymy and holonymy. Various calculi that attempt to capture the theoretical properties of object-oriented programming may be derived from system F <. In a theoretical setting, it is desirable to study the interaction of the two features a common theoretical setting is system F <. Typically, functional programming languages also provide some, usually restricted, form of parametric polymorphism. 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. Because the resulting calculus allows terms to have more than one type, it is no longer a "simple" type theory. 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. 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.įunctional programming languages often allow the subtyping of records. Subtyping is therefore a form of type polymorphism. 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.ĭue to the subtyping relation, a term may belong to more than one type. 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. If S is a subtype of T, the subtyping relation (written as S <: T, S ⊑ T, 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. 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. In programming language theory, subtyping (also called subtype polymorphism or inclusion polymorphism) is a form of type polymorphism.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |