Bounded quantification
Encyclopedia
In type theory
, 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
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.
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: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:External links
- Bounded Polymorphism at the Portland Pattern RepositoryPortland Pattern RepositoryThe Portland Pattern Repository is a repository for computer programming design patterns. It was accompanied by a companion website, WikiWikiWeb, which was the world's first wiki....
- "F-bounded Polymorphism" in The Cecil Language: Specification and Rationale
- WTF is F-Bounded Polymorphism
- The Java Program: OrderedList.java