Base 弃用了一些有用的函数

Base deprecates some useful functions

我习惯在 OCaml 中使用标准函数 print_int,但是当我按照 Real World OCaml 一书中的建议打开 Jane Street 的库 Base 时,我收到弃用警告:

utop # print_int;;
- : int -> unit = <fun>
utop # open Base;;
utop # print_int;;
Line 1, characters 0-9:
Alert deprecated: Base.print_int
- : int -> unit = <fun>

更糟糕的是,当我按照那本书的建议使用 dune 构建它时,警告变成了错误。我应该怎么办 ?将 print_int 替换为 printf "%i" ?或 Caml.print_int ?两者似乎都有效,但看起来不必要地复杂。还有别的吗? 谢谢。

此处回答:https://ocaml.janestreet.com/ocaml-core/v0.13/doc/base/index.html#using-the-ocaml-standard-library-with-base

Base is intended as a full stdlib replacement. As a result, after an open Base, all the modules, values, types, etc., coming from the OCaml standard library that one normally gets in the default environment are deprecated.

In order to access these values, one must use the Caml library, which re-exports them all through the toplevel name Caml: Caml.String, Caml.print_string, ...