ocaml - 令人困惑的 OCaml Base/Core 库弃用警告
问题描述
几个小时以来,我一直在尝试 Jane Street 的 Base / Core 库,但我对弃用警告感到非常困惑。
使用以下代码:
open Base
(* open Core *)
open Stdio
let _ = printf "%d" (4 mod 3)
我收到弃用警告:
Alert deprecated: Base.mod
[2016-09] this element comes from the stdlib distributed with OCaml.
Use (%), which has slightly different semantics, or Int.rem which is equivalent.
我知道我必须使用%
or Int.rem
,但是当我简单地使用时open Core
,警告就会消失。该文档似乎没有对这些“弃用”进行太多说明。
此外,使用以下代码:
(* open Base *)
open Core
(* open Stdio *)
let _ = Out_channel.output_string stdout "Hello, OCaml"
let line = In_channel.input_line_exn stdin
我明白了
Alert deprecated: Core.stdin
[since 2016-04] Use [In_channel.stdin]
但令人惊讶的是,没有警报stdout
。
当我取消注释该(* open Stdio *)
行时,我不再收到警告。我可以猜测 Stdio 模块可能会影响标准输入/标准输出,但我认为open Core
这已经足够了,因为它取决于 Stdio 模块。
我用了
ocamlfind ocamlopt -o output.out -linkpkg -package base,stdio -thread output.ml
和-package base,stdio
,分别。
为什么我在使用 'mod' 时没有收到弃用警告
open Core
,如果它在我使用时警告我open Base
?为什么我没有收到警报
stdout
?
2-1。正常的open Stdio
时候我也有必要open Core
吗?
解决方案
推荐阅读
- mysql - 在 MariaDB 中跳过锁定的替代方案
- angular-material - 在柏树中获取第 n 个 mat-row
- github - 在将代码从 VS CODE 移动到 Github 时面临“这超出了 GitHub 的文件大小限制 100.00 MB”的错误
- javascript - 从扩展中是否可以在页面加载时以编程方式捕获站点的 CSP?
- keras - 表格数据的“卷积一维”神经网络训练中的“loss : nan”
- javascript - 在 Cognos 中应用多提示验证
- python - Pandas:WiFi 日志中按小时计算的唯一每日值
- javascript - 如何在使用 fetch api 发布响应后读取字符串值
- xml - 用 XSLT 中的元素包围匹配的兄弟姐妹
- titanium - 如何创建随机抖动的图像