val new : string -> stringref (* returns a unique new stringref *)
val name : stringref -> string (* returns the name of a stringref *)
val compare : stringref * stringref -> order (* comparison function *)
+ val all : unit -> (stringref * string) list
end
structure Stringref :> STRINGREF =
(* warning: calling reset() may jeopardize uniqueness of stringrefs! *)
fun reset () = ( counter := 1 ; strings := [] )
fun new (s : string) = !counter before ( strings := (!counter, s) :: !strings ; counter := !counter + 1 )
+ fun all () = !strings
end
fun name t = "S" ^ Int.toString t