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'a
t ='a option Pervasives.ref * string
val empty : 'a -> 'b option Pervasives.ref * 'a
val name : 'a * 'b -> 'b
val set : 'a option Pervasives.ref * 'b -> 'a -> unit
val get : 'a option Pervasives.ref * string -> 'a
val getd : 'a -> 'a option Pervasives.ref * 'b -> 'a
val undef : 'a option Pervasives.ref * 'b -> unit
val isdef : 'a option Pervasives.ref * 'b -> bool
true
if the global value has been set.val opt : 'a Pervasives.ref * 'b -> 'a
None
if the global is undefined, else Some v
where v is the
current global value contents.