Bounded quantification
Encyclopedia
In type theory
Type theory
In mathematics, logic and computer science, type theory is any of several formal systems that can serve as alternatives to naive set theory, or the study of such formalisms in general...

, bounded quantification (also bounded polymorphism or bounded 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
Parametric polymorphism
In programming languages and type theory, parametric polymorphism is a way to make a language more expressive, while still maintaining full static type-safety. Using parametric polymorphism, a function or a data type can be written generically so that it can handle values identically without...

 with subtyping. Bounded quantification has traditionally been studied in the functional
Functional programming
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...

 setting of System F<:, but is available in modern object-oriented languages supporting parametric polymorphism (generics) such as Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

, 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 {
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 the of the binders occurring on the left-hand side:


class I {
}

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

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK