Permalink
Browse files

rename Global.get for _exn, add tests

  • Loading branch information...
thelema committed Mar 2, 2012
1 parent df6c0cd commit 93ec10d36d6834bb981c1e65f4f81c210821d843
Showing with 12 additions and 13 deletions.
  1. +2 −1 src/batGlobal.ml
  2. +10 −12 src/batGlobal.mli
View
@@ -33,7 +33,7 @@ let name = snd
let set (r, _) v =
r := Some v
-let get (r, name) =
+let get_exn (r, name) =
match !r with
| None -> raise (Global_not_initialized name)
| Some v -> v
@@ -47,4 +47,5 @@ let isdef (r, _) =
let opt (r, _) =
!r
+let get (r,_) = !r
(*BISECT-IGNORE-END*)
View
@@ -38,30 +38,28 @@ exception Global_not_initialized of string
assigned a value. The parameter contains the name of the global. *)
val empty : string -> 'a t
-(** Returns an new named empty global. The name of the global can be any
- string. It identifies the global and makes debugging easier. *)
+(** Returns 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 -> string
(** Retrieve the name of a global. *)
val set : 'a t -> 'a -> unit
(** Set the global value contents. *)
-val get : 'a t -> 'a
+val get_exn : 'a t -> 'a
(** Get the global value contents - raise Global_not_initialized if not
defined. *)
+val get : 'a t -> 'a option
+(** Return [None] if the global is undefined, else [Some v] where [v] is
+ the current global value contents. *)
+
val undef : 'a t -> unit
(** Reset the global value contents to undefined. *)
val isdef : 'a t -> bool
(** Return [true] if the global value has been set. *)
-
-val opt : 'a t -> 'a option
- (** Return [None] if the global is undefined, else [Some v] where v is the
- current global value contents. *)
-
-(** {6 Boilerplate code}*)
-
-
-

0 comments on commit 93ec10d

Please sign in to comment.