Bounded quantification

Uses your system voice; voice and rate in settings.

Snapshot

≈ 2 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

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.

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. \texttt{Comparable } = \{\texttt{compareTo}: T \to \texttt{int}\} Consider the following possible declarations in java.lang : package java.lang; public interface Comparable { int compareTo(T other); } public class Integer implements Comparable { @Override public int compareTo(Integer other) { // ... } } public class String implements Comparable { @Override public int compareTo(String other) { // ... } } Then, in use: package org.wikipedia.examples; public class Test { public static S min(S a, S b) { if (a.compareTo(b) > T fMin(T a, T b) { if (a.compareTo(b) Peter S. Canning, William R. Cook, Walter L. Hill, John C. Mitchell, and William Olthoff. "F-bounded polymorphism for object-oriented programming". In Conference on Functional Programming Languages and Computer Architecture, 1989. Benjamin C. Pierce "Intersection types and bounded polymorphism". Lecture Notes in Computer Science 664, 1993. Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. "Making the future safe for the past: Adding genericity to the Java programming language". In Object-Oriented Programming: Systems, Languages, Applications (OOPSLA). ACM, October 1998. Andrew Kennedy and Don Syme. "Design and Implementation of Generics for the .NET Common Language Runtime". In Programming Language Design and Implementation, 2001. , Chapter 26: Bounded quantification

Text derived from https://en.wikipedia.org/w/index.php?oldid=1367554656 under CC BY-SA 4.0; modifications have been made.