Reputation: 1912
I've been trying Jane Street's Base / Core libraries for a few hours now, and I got very confused by depracation warnings.
With the following code:
open Base
(* open Core *)
open Stdio
let _ = printf "%d" (4 mod 3)
I get a deprecation warning:
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.
I get that I have to use %
or Int.rem
, but when I simply open Core
, the warning disappears.
The documentation doesn't seem to clarify much regarding these 'deprecations'.
Also, with the following code:
(* open Base *)
open Core
(* open Stdio *)
let _ = Out_channel.output_string stdout "Hello, OCaml"
let line = In_channel.input_line_exn stdin
I get
Alert deprecated: Core.stdin
[since 2016-04] Use [In_channel.stdin]
but surprisingly, no alert for stdout
.
When I uncomment the (* open Stdio *)
line, I no longer get warnings.
I can guess that Stdio module is probably shadowing the stdin/stdout, but I thought open Core
was enough for this as it depends on the Stdio module.
I used
ocamlfind ocamlopt -o output.out -linkpkg -package base,stdio -thread output.ml
and with -package base,stdio
, respectively.
Why am I not getting a deprecation warning for 'mod' when I use open Core
, if it warned me if I used open Base
?
Why am I getting no alert for stdout
?
2-1. Is it normal necessary to open Stdio
as well when I open Core
?
Upvotes: 3
Views: 658