caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* confusion about mutable strings
@ 2008-02-10 17:46 Ralph Douglass
  2008-02-10 18:03 ` [Caml-list] " Bünzli Daniel
  0 siblings, 1 reply; 6+ messages in thread
From: Ralph Douglass @ 2008-02-10 17:46 UTC (permalink / raw)
  To: Caml List

[-- 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 --]

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

end of thread, other threads:[~2008-02-12 19:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-10 17:46 confusion about mutable strings 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
2008-02-11 13:46       ` Ralph Douglass
2008-02-12 19:33         ` Ashish Agarwal

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).