Go backward to
Basic and Structured Types
Go up to
Top
Go forward to
Variant Types and Recursion
Record Types
Example:
type ARec = {a: Int, b: Bool}
value r: ARec = {a = 3, b = true}
r.b
Functions as components:
type FunRec = {f1: Int
->
Int, f2: Real
->
Real}
value funRec: FunRec = {f1 = succ, f2 = sin}
Concatenation of record types:
type NewRec = FunRec & {f3: Bool
->
Bool}
Private data structures:
value counter =
let count = ref(0) in
{ inc = fun(n:Int) count := count+n
total = fun() count
}
counter.inc(3), counter.total()
Author:
Wolfgang Schreiner
Last Modification: May 27, 1998