summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKC Sivaramakrishnan <kc@kcsrk.info>2021-06-12 21:06:53 +0530
committerKC Sivaramakrishnan <kc@kcsrk.info>2021-06-12 21:06:53 +0530
commitbe0ea3ff67c714fab67897335deb33de8d3d6f0c (patch)
tree88b417f15d8f9474045782bd2f05b13a8959ec14
parent404ac5b938cdb6dbfdbaf0c1d4baba16b1eccfa6 (diff)
downloadocaml-be0ea3ff67c714fab67897335deb33de8d3d6f0c.tar.gz
Use sensible variable names. Update documentation.
-rw-r--r--stdlib/filename.ml4
-rw-r--r--stdlib/hashtbl.ml6
-rw-r--r--stdlib/random.mli19
3 files changed, 15 insertions, 14 deletions
diff --git a/stdlib/filename.ml b/stdlib/filename.ml
index 142ed05bde..fb5df724b7 100644
--- a/stdlib/filename.ml
+++ b/stdlib/filename.ml
@@ -327,10 +327,10 @@ let remove_extension name =
external open_desc: string -> open_flag list -> int -> int = "caml_sys_open"
external close_desc: int -> unit = "caml_sys_close"
-let random_key = Domain.DLS.new_key Random.State.make_self_init
+let prng_key = Domain.DLS.new_key Random.State.make_self_init
let temp_file_name temp_dir prefix suffix =
- let random_state = Domain.DLS.get random_key in
+ let random_state = Domain.DLS.get prng_key in
let rnd = (Random.State.bits random_state) land 0xFFFFFF in
concat temp_dir (Printf.sprintf "%s%06x%s" prefix rnd suffix)
diff --git a/stdlib/hashtbl.ml b/stdlib/hashtbl.ml
index 069ee9b593..6aba9cb2c5 100644
--- a/stdlib/hashtbl.ml
+++ b/stdlib/hashtbl.ml
@@ -57,7 +57,7 @@ let randomized = ref randomized_default
let randomize () = randomized := true
let is_randomized () = !randomized
-let random_key = Domain.DLS.new_key Random.State.make_self_init
+let prng_key = Domain.DLS.new_key Random.State.make_self_init
(* Functions which appear before the functorial interface must either be
independent of the hash function or take it as a parameter (see #2202 and
@@ -72,7 +72,7 @@ let rec power_2_above x n =
let create ?(random = !randomized) initial_size =
let s = power_2_above 16 initial_size in
- let random_state = Domain.DLS.get random_key in
+ let random_state = Domain.DLS.get prng_key in
let seed = if random then Random.State.bits random_state else 0 in
{ initial_size = s; size = 0; seed = seed; data = Array.make s Empty }
@@ -618,7 +618,7 @@ let of_seq i =
let rebuild ?(random = !randomized) h =
let s = power_2_above 16 (Array.length h.data) in
let seed =
- let random_state = Domain.DLS.get random_key in
+ let random_state = Domain.DLS.get prng_key in
if random then Random.State.bits random_state
else if Obj.size (Obj.repr h) >= 4 then h.seed
else 0 in
diff --git a/stdlib/random.mli b/stdlib/random.mli
index f8eae5fac9..137b243d15 100644
--- a/stdlib/random.mli
+++ b/stdlib/random.mli
@@ -18,18 +18,18 @@
(** {1 Basic functions} *)
val init : int -> unit
-(** Initialize the generator, using the argument as a seed.
- The same seed will always yield the same sequence of numbers. *)
+(** Initialize the domain-local generator, using the argument as a seed.
+ The same seed will always yield the same sequence of numbers. *)
val full_init : int array -> unit
(** Same as {!Random.init} but takes more data as seed. *)
val self_init : unit -> unit
-(** Initialize the generator with a random seed chosen
- in a system-dependent way. If [/dev/urandom] is available on
- the host machine, it is used to provide a highly random initial
- seed. Otherwise, a less random seed is computed from system
- parameters (current time, process IDs). *)
+(** Initialize the domain-local generator with a random seed chosen
+ in a system-dependent way. If [/dev/urandom] is available on the host
+ machine, it is used to provide a highly random initial seed. Otherwise, a
+ less random seed is computed from system parameters (current time, process
+ IDs). *)
val bits : unit -> int
(** Return 30 random bits in a nonnegative integer.
@@ -101,7 +101,8 @@ end
val get_state : unit -> State.t
-(** Return the current state of the generator used by the basic functions. *)
+(** Return the current domain-local state of the generator used by the basic
+ functions. *)
val set_state : State.t -> unit
-(** Set the state of the generator used by the basic functions. *)
+(** Set the domain-local state of the generator used by the basic functions. *)