From: "Ralph Douglass" <ralph@grayskies.net>
To: "Caml List" <caml-list@inria.fr>
Subject: confusion about mutable strings
Date: Sun, 10 Feb 2008 12:46:19 -0500 [thread overview]
Message-ID: <71767b800802100946o4d465b79xad9b1f9515f7e69f@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 608 bytes --]
I'm a little confused by some behavior I'm seeing. Here is an example from
the toplevel:
# let foo () =
let str = "ffff" in
Printf.printf "%s\n%!" str;
str.[0] <- 'r';
str.[1] <- 'r';
str.[2] <- 'r';
str.[3] <- 'r';
str
;;
val foo : unit -> string = <fun>
# foo ();;
ffff
- : string = "rrrr"
# foo ();;
rrrr
- : string = "rrrr"
#
Why isn't the output for the second printf also "ffff"? It seems like it's
completely ignoring "let str =" the second time.
Any thoughts? Is this a bug, or something I just don't know about?
3.10.1 on intel osx 10.5.1, installed from godi.
Thanks,
Ralph
[-- Attachment #2: Type: text/html, Size: 893 bytes --]
next reply other threads:[~2008-02-10 17:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-10 17:46 Ralph Douglass [this message]
2008-02-10 18:03 ` [Caml-list] " Bünzli Daniel
2008-02-11 0:22 ` Ralph Douglass
2008-02-11 10:01 ` Loup Vaillant
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=71767b800802100946o4d465b79xad9b1f9515f7e69f@mail.gmail.com \
--to=ralph@grayskies.net \
--cc=caml-list@inria.fr \
/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