Skip to content

Make lazy.ml independent of the runtime version #2080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions ocaml/stdlib/lazy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ type 'a t = 'a CamlinternalLazy.t
exception Undefined = CamlinternalLazy.Undefined
external make_forward : 'a -> 'a lazy_t = "caml_lazy_make_forward"
external force : 'a t -> 'a = "%lazy_force"
external runtime5 : unit -> bool = "%runtime5"
let runtime5 = runtime5 ()

let force_val l = CamlinternalLazy.force_gen ~only_val:true l

Expand All @@ -67,7 +65,7 @@ let from_fun (f : unit -> 'arg) =
Obj.set_field x 0 (Obj.repr f);
(Obj.obj x : 'arg t)

let from_val4 (v : 'arg) =
let from_val (v : 'arg) =
let t = Obj.tag (Obj.repr v) in
if t = Obj.forward_tag || t = Obj.lazy_tag ||
t = Obj.forcing_tag || t = Obj.double_tag then begin
Expand All @@ -76,18 +74,6 @@ let from_val4 (v : 'arg) =
(Obj.magic v : 'arg t)
end

let from_val5 (v : 'arg) =
let t = Obj.tag (Obj.repr v) in
if t = Obj.forward_tag || t = Obj.lazy_tag
|| t = Obj.forcing_tag
|| t = Obj.double_tag then begin
make_forward v
end else begin
(Obj.magic v : 'arg t)
end

let from_val = if runtime5 then from_val5 else from_val4

let is_val (l : 'arg t) = Obj.tag (Obj.repr l) <> Obj.lazy_tag

let map f x =
Expand Down