Go backward to Record Types and Inheritance
Go up to Top
Go forward to Object Oriented Programming
Bounded Quantification 'n Subtyping
- Mix subtyping and polymorphism.
- value f = fun(x: {one: Int}) x.one
f({one = 3, two = true})
- value f = all[a] fun(x: {one: a}) x.one
f[Int]({one = 3, two = true})
- Constraint all[a <=T] e
- value g = all[a <= {one: Int}] fun(x: a) x.one
g[{one:Int, two:Bool}]({one=3, two=true})
- Two forms of inclusion constraints:
- In f, implicit by function parameters.
- In g, explicit by bounded quantification.
- Type expressions:
- g: forall a <= {one: Int}. a Int
- Type abstraction:
- value g = all[b] all[a<={one: b}] fun(x:a)x:one
g[Int][({one:Int,two:Bool})]({one=3,...})
Wolfgang.Schreiner@risc.uni-linz.ac.at
Id: understand.tex,v 1.1 1996/06/12 09:38:21 schreine Exp schreine