make the #use_output directive compatible with ocaml >= 4.02

This commit is contained in:
ZAN DoYe 2020-03-25 09:58:22 +08:00
parent 3f735497d9
commit 692b92794d
1 changed files with 8 additions and 1 deletions

View File

@ -748,9 +748,16 @@ let () =
+-----------------------------------------------------------------+ *) +-----------------------------------------------------------------+ *)
let try_finally ~always work=
#if OCAML_VERSION >= (4, 08, 0)
Misc.try_finally ~always work
#else
Misc.try_finally work always
#endif
let use_output command = let use_output command =
let fn = Filename.temp_file "ocaml" "_toploop.ml" in let fn = Filename.temp_file "ocaml" "_toploop.ml" in
Misc.try_finally ~always:(fun () -> try_finally ~always:(fun () ->
try Sys.remove fn with Sys_error _ -> ()) try Sys.remove fn with Sys_error _ -> ())
(fun () -> (fun () ->
match match