Re: safe-string option not working in toplevel ?

"Gabriel Scherer [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAPFanBF_X8+ZS7fR1rVKJMkm0soV8hQrCGLFvHp5PoFv+NiwTw@mail.gmail.com>
String.set is available in both modes, the only difference is what its type
allows you. Without safe-string, types "string" and "bytes" are considered
equivalent by the type-checker. So you can apply String.set to either a
string or a byte sequence. With -safe-string, they are distinct types, so
you can only use it on what its type says: bytes in the case of String.set.
This means that you cannot use the String.set function on strings (try
(String.set "foo" 0 'r') for example), only on bytes. It is deprecated
because you should use Bytes.set to express your intent more clearly (but
then String.set is still available to preserve backward-compatibility).

On Tue, May 5, 2015 at 9:06 AM, [email protected] [ocaml_beginners] <
[email protected]> wrote:

>
>
>
>   According to the section of the Manual on the String module, the
> String.set function should not be usable when the safe-string option is set.
>
>   But I see no difference :
>
> Ordinary ewandelanoy$ ocaml
>         OCaml version 4.02.1
>
>
> # String.set;;
> Warning 3: deprecated: String.set
> Use Bytes.set instead.
> - : bytes -> int -> char -> unit = <fun>
> # #quit;;
> Ordinary ewandelanoy$ ocaml -safe-string
>         OCaml version 4.02.1
>
>
> # String.set;;
> Warning 3: deprecated: String.set
> Use Bytes.set instead.
> - : bytes -> int -> char -> unit = <fun>
>
>
>
> Am I missing something or writing something wrong ?
>
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.