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
0
= fun(x: {one: Int}) x.one
f
0
({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
0
= all[a <= {one: Int}] fun(x: a) x.one
g
0
[{one:Int, two:Bool}]({one=3, two=true})
Two forms of inclusion constraints:
In f
0
, implicit by function parameters.
In g
0
, explicit by bounded quantification.
Type expressions:
g
0
:
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,...})
Author:
Wolfgang Schreiner
Last Modification: May 27, 1998