Subject: [Caml-list] String.create

From: Sylvain Pogodalla <[email-masked]>
Date: Wed, 22 Oct 2014 11:29:36 +0200

Hi,

Sébastien Hinderer writes:
 > OCaml 4.02.0 prints the following warning:
 > Warning 3: deprecated: String.create

(...)

 > Is there a way to fix the code so that it does not trigger this warning
 > but still compiles also with older versions of Caml, up to 3.10?

You can pass the -w -3 option to the compiler to disable waring
messages on deprecated features.

Hop this helps.

S.

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

---

From: Sébastien Hinderer <[email-masked]>
Date: Wed, 22 Oct 2014 11:14:39 +0200

Dear all,

The code that triggers this warning looks like this:

let buf = String.create size in
really_input ic buf 0 size;

Many thanks!
Sébastien.

---

From: [email-masked]
Date: Wed, 22 Oct 2014 13:26:05 +0400

> but still compiles also with older versions of Caml, up to 3.10?

String.make

-- 
mailto:[email-masked]

---

From: David Allsopp <[email-masked]>
Date: Wed, 22 Oct 2014 09:27:26 +0000

> but still compiles also with older versions of Caml, up to 3.10?

Yes - write your code to use Bytes (http://caml.inria.fr/pub/docs/manual-ocaml/libref/Bytes.html) and then add a requirement for findlib >= 1.5 which includes the "bytes" package (this is a dummy package for OCaml >= 4.02 and a compatibility layer for OCaml < 4.02).

Alternatively, if for some very strange reason you're not happy to depend on findlib, you can borrow its compatibility layer directly (src/bytes/bytes.ml) and integrate that into your build system.

David

---

From: David Allsopp <[email-masked]>
Date: Wed, 22 Oct 2014 09:31:43 +0000

[email-masked] wrote:
> > Is there a way to fix the code so that it does not trigger this
> > warning but still compiles also with older versions of Caml, up to 3.10?
> >
> 
> String.make

Not a great solution (even ignoring the semantic differences between Bytes.create and String.make) - really_input has signature in_channel -> *bytes* -> int -> int -> unit for OCaml >= 4.02, so this will break in the future when -safe-string becomes the default.

David