Bounded quantification

From Wikipedia, the free encyclopedia

In type theory, bounded quantification (also bounded polymorphism or constrained genericity) refers to universal or existential quantifiers which are restricted ("bounded") to range only over the subtypes of a particular type. Bounded quantification is an interaction of parametric polymorphism with subtyping. Bounded quantification has traditionally been studied in the functional setting of System F<:, but is available in modern object-oriented languages supporting parametric polymorphism (generics) such as Java, C# and Scala.

Example

In the following Java sample the type parameter T is bounded to range only over I and its subclasses:

class I {
}
 
class A <T extends I> {
    public T id(T x) {
        return x;
    }
}

F-bounded quantification

We speak of F-bounded quantification or recursively bounded quantification if the subtype constraint itself is parametrized by one of the binders occurring on the left-hand side:

class I<T> {
}
 
class A <T extends I<T>> {
    public T id(T x) {
        return x;
    }
}

See also

References

External links

This article is issued from Wikipedia. The text is available under the Creative Commons Attribution/Share Alike; additional terms may apply for the media files.