| 1 |
(* |
| 2 |
Prior to OCaml 4.13.0, [load_file] was in the Topdirs module. |
| 3 |
Beginning with OCaml 4.13.0, load_file is in the Toploop module. |
| 4 |
In order to be able to compile with OCaml versions either |
| 5 |
before or after, open both modules and let the compiler |
| 6 |
find [load_file] where it is defined. |
| 7 |
*) |
| 8 |
open Topdirs [@@ocaml.warning "-33"] |
| 9 |
open Toploop [@@ocaml.warning "-33"] |
| 10 |
|
| 11 |
let load filename = |
| 12 |
let buf = Buffer.create 16 in |
| 13 |
let ppf = Format.formatter_of_buffer buf in |
| 14 |
match load_file ppf filename with |
| 15 |
| true -> () |
| 16 |
| false -> |
| 17 |
Format.pp_print_flush ppf (); |
| 18 |
failwith |
| 19 |
@@ Format.asprintf "Failed to load file `%s': %s" filename (Buffer.contents buf) |
| 20 |
;; |