caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] String.create
@ 2014-10-22  9:14 Sébastien Hinderer
  2014-10-22  9:26 ` av1474
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sébastien Hinderer @ 2014-10-22  9:14 UTC (permalink / raw)
  To: caml-list

Dear all,

OCaml 4.02.0 prints the following warning:
Warning 3: deprecated: String.create

The code that triggers this warning looks like this:

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

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?

Many thanks!
Sébastien.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] String.create
  2014-10-22  9:14 [Caml-list] String.create Sébastien Hinderer
@ 2014-10-22  9:26 ` av1474
  2014-10-22  9:31   ` David Allsopp
  2014-10-22  9:27 ` David Allsopp
  2014-10-22  9:29 ` Sylvain Pogodalla
  2 siblings, 1 reply; 5+ messages in thread
From: av1474 @ 2014-10-22  9:26 UTC (permalink / raw)
  To: Sébastien Hinderer; +Cc: caml-list

Sébastien Hinderer <Sebastien.Hinderer@inria.fr> writes:

> Dear all,
>
> OCaml 4.02.0 prints the following warning:
> Warning 3: deprecated: String.create
>
> The code that triggers this warning looks like this:
>
> let buf = String.create size in
> really_input ic buf 0 size;
>
> 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

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Caml-list] String.create
  2014-10-22  9:14 [Caml-list] String.create Sébastien Hinderer
  2014-10-22  9:26 ` av1474
@ 2014-10-22  9:27 ` David Allsopp
  2014-10-22  9:29 ` Sylvain Pogodalla
  2 siblings, 0 replies; 5+ messages in thread
From: David Allsopp @ 2014-10-22  9:27 UTC (permalink / raw)
  To: caml-list

Sébastien Hinderer wrote:
> OCaml 4.02.0 prints the following warning:
> Warning 3: deprecated: String.create
> 
> The code that triggers this warning looks like this:
> 
> let buf = String.create size in
> really_input ic buf 0 size;
> 
> 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?

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Caml-list]  String.create
  2014-10-22  9:14 [Caml-list] String.create Sébastien Hinderer
  2014-10-22  9:26 ` av1474
  2014-10-22  9:27 ` David Allsopp
@ 2014-10-22  9:29 ` Sylvain Pogodalla
  2 siblings, 0 replies; 5+ messages in thread
From: Sylvain Pogodalla @ 2014-10-22  9:29 UTC (permalink / raw)
  To: Sébastien Hinderer; +Cc: caml-list

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Caml-list] String.create
  2014-10-22  9:26 ` av1474
@ 2014-10-22  9:31   ` David Allsopp
  0 siblings, 0 replies; 5+ messages in thread
From: David Allsopp @ 2014-10-22  9:31 UTC (permalink / raw)
  To: caml-list

av1474@comtv.ru wrote:
> Sébastien Hinderer <Sebastien.Hinderer@inria.fr> writes:
> 
> > Dear all,
> >
> > OCaml 4.02.0 prints the following warning:
> > Warning 3: deprecated: String.create
> >
> > The code that triggers this warning looks like this:
> >
> > let buf = String.create size in
> > really_input ic buf 0 size;
> >
> > 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-22  9:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-22  9:14 [Caml-list] String.create Sébastien Hinderer
2014-10-22  9:26 ` av1474
2014-10-22  9:31   ` David Allsopp
2014-10-22  9:27 ` David Allsopp
2014-10-22  9:29 ` Sylvain Pogodalla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).