ref: operations on references
type 'a ref = ref of mutable 'a
-
The type of references (mutable indirection cells) containing
a value of type 'a.
value prefix ! : 'a ref -> 'a
-
!r returns the current contents of reference r.
Could be defined as fun (ref x) -> x.
value prefix := : 'a ref -> 'a -> unit
-
r := a stores the value of a in reference r.
value incr : int ref -> unit
-
Increment the integer contained in the given reference.
Could be defined as fun r -> r := succ !r.
value decr : int ref -> unit
-
Decrement the integer contained in the given reference.
Could be defined as fun r -> r := pred !r.