package batteries
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=e4b70d1a716f0aaba36f419f618d0a2e
sha512=a31f1f8cf2c7c3c6c757f3bfae98ff61bb32bab6a1f1e215937df42bcfa447aad41a37edb28d7bcecb88b3838ed8bd57142bcf8e2d28e09bb538055fd8a3b72d
doc/batteries.unthreaded/BatGlobal/index.html
Module BatGlobal
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.
Raised when a global variable is accessed without first having been assigned a value. The parameter contains the name of the global.
val empty : string -> 'a tReturns an new named empty global. The name of the global can be any string. It identifies the global and makes debugging easier. Using the same string twice will not return the same global twice, but will create two globals with the same name.
val name : 'a t -> stringRetrieve the name of a global.
val set : 'a t -> 'a -> unitSet the global value contents.
val get_exn : 'a t -> 'aGet the global value contents - raise Global_not_initialized if not defined.
val get : 'a t -> 'a optionReturn None if the global is undefined, else Some v where v is the current global value contents.
val undef : 'a t -> unitReset the global value contents to undefined.
val isdef : 'a t -> boolReturn true if the global value has been set.