From: fva <fv...@ts...> - 2003-02-28 10:08:37
|
Nicolas Cannasse wrote: >I also have mine, but in a different way ( that's "named" globals - better >debug & type abstraction ) >But since I hasn't used it much, I was wondering if it should be part of the >ExtLib, maybe ? > > >exception Global_not_initialized of string > >module Global : > sig > > type 'a t > > val empty : string -> 'a t (* returns an new named empty global *) > val name : 'a t -> string (* retrieve the name of a global *) > val set : 'a t -> 'a -> unit (* set the global value contents *) > val get : 'a t -> 'a (* get the global value contents - raise >Global_not_initialized if not defined *) > val undef : 'a t -> unit (* reset the global value contents to undefined *) > val isdef : 'a t -> bool (* tell if the global value has been set *) > > val opt : 'a t -> 'a option (* return None if the global is undefined, or >Some v where v is the current global value contents *) > > end > I've also something similar for generating new names, etc... I think it worth putting in an extended lib. Regards, Fva |