module Global:Modified Global module from Extlib library, Copyright (C) 2003 Nicolas Cannassesig..end
Mutable global variable.
Often in OCaml you want to have a global variable, which is mutable
and uninitialized when declared. You can use a 'a option ref but
this is not very convenient. The Global module provides functions
to easily create and manipulate such variables.
exception Global_not_initialized of string
type'at ='a option Pervasives.ref * string
val empty : 'a -> 'b option Pervasives.ref * 'aval name : 'a * 'b -> 'bval set : 'a option Pervasives.ref * 'b -> 'a -> unitval get : 'a option Pervasives.ref * string -> 'aval getd : 'a -> 'a option Pervasives.ref * 'b -> 'aval undef : 'a option Pervasives.ref * 'b -> unitval isdef : 'a option Pervasives.ref * 'b -> booltrue if the global value has been set.val opt : 'a Pervasives.ref * 'b -> 'aNone if the global is undefined, else Some v where v is the
current global value contents.