(* $Id: ostack.ml,v 1.7 2002/08/04 10:32:54 garrigue Exp $ *) exception Empty class ['a] c () = object val mutable s : 'a list = [] method push x = s <- x :: s method pop = match s with x::s' -> s <- s'; x | [] -> raise Empty method top = match s with x::_ -> x | [] -> raise Empty method clear = s <- [] method copy = {< s = s >} method is_empty = s = [] method length = List.length s method iter ~f = List.iter f s method contents = s end