caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Loup Vaillant" <loup.vaillant@gmail.com>
To: "Ralph Douglass" <ralph@grayskies.net>
Cc: "Bünzli Daniel" <daniel.buenzli@erratique.ch>,
	"Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] confusion about mutable strings
Date: Mon, 11 Feb 2008 11:01:51 +0100	[thread overview]
Message-ID: <6f9f8f4a0802110201k5e81e65ft7dcbb9773be34f76@mail.gmail.com> (raw)
In-Reply-To: <71767b800802101622j45fd0db4id4351b44fb1f9cf3@mail.gmail.com>

2008/2/11, Ralph Douglass <ralph@grayskies.net>:
>
> Observe the following:
>
> # let foo () =
>   let bar = [|'a';'b';'c'|] in
>   Array.iter (Printf.printf "%c") bar;
>   bar.(0) <- 'd';
>   bar;;
> val foo : unit -> char array = <fun>
>  # foo ();;
> abc- : char array = [|'d'; 'b'; 'c'|]
> # foo ();;
> abc- : char array = [|'d'; 'b'; 'c'|]
>
> Why does OCaml treat these two examples in such a different manner?  Is
> there a reason why strings are magically special in this way?

C strings are usually "magically special" in exactly the same way. It
has been talked about in another thread (dunno how to look for it).
Basically, this is a design choice meant for better performance.

Loup


  reply	other threads:[~2008-02-11 10:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10 17:46 Ralph Douglass
2008-02-10 18:03 ` [Caml-list] " Bünzli Daniel
2008-02-11  0:22   ` Ralph Douglass
2008-02-11 10:01     ` Loup Vaillant [this message]
2008-02-11 13:46       ` Ralph Douglass
2008-02-12 19:33         ` Ashish Agarwal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f9f8f4a0802110201k5e81e65ft7dcbb9773be34f76@mail.gmail.com \
    --to=loup.vaillant@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    --cc=ralph@grayskies.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).