aboutsummaryrefslogtreecommitdiff
path: root/lib/dyn.ml
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2015-12-04 21:46:12 +0100
committerPierre-Marie Pédrot2015-12-04 21:55:31 +0100
commit153d77d00ccbacf22aa5d70ca2c1cacab2749339 (patch)
tree98997d190ad1b45f3096473c1015feae55b64efe /lib/dyn.ml
parent0aba678e885fa53fa649de59eb1d06b4af3a847c (diff)
Specializing the Dyn module to each usecase.
Actually, we never mix the various uses of each dynamic type created through the Dyn module. To enforce this statically, we functorize the Dyn module so that we recover a fresh instance at each use point.
Diffstat (limited to 'lib/dyn.ml')
-rw-r--r--lib/dyn.ml15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/dyn.ml b/lib/dyn.ml
index 056b687313..60167ef1ba 100644
--- a/lib/dyn.ml
+++ b/lib/dyn.ml
@@ -9,6 +9,19 @@
open Errors
open Pp
+module type S =
+sig
+type t
+
+val create : string -> ('a -> t) * (t -> 'a)
+val tag : t -> string
+val has_tag : t -> string -> bool
+val pointer_equal : t -> t -> bool
+val dump : unit -> (int * string) list
+end
+
+module Make(M : CSig.EmptyS) =
+struct
(* Dynamics, programmed with DANGER !!! *)
type t = int * Obj.t
@@ -48,3 +61,5 @@ let tag (s,_) =
let pointer_equal (t1,o1) (t2,o2) = t1 = t2 && o1 == o2
let dump () = Int.Map.bindings !dyntab
+
+end \ No newline at end of file