From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id D8FC7BC6B for ; Sun, 10 Feb 2008 18:46:29 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGLHrkfAXQImh2dsb2JhbACCPDWNSQEBAQgKKZU2 X-IronPort-AV: E=Sophos;i="4.25,330,1199660400"; d="scan'208";a="7873870" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 Feb 2008 18:46:29 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m1AHkMLT014215 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 10 Feb 2008 18:46:29 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKPHrkdA6bL5mWdsb2JhbACCPDWNSQEBAQEBBgQECwgYlTU X-IronPort-AV: E=Sophos;i="4.25,330,1199660400"; d="scan'208";a="7140655" Received: from hs-out-0708.google.com (HELO hs-out-2122.google.com) ([64.233.178.249]) by mail2-smtp-roc.national.inria.fr with ESMTP; 10 Feb 2008 18:46:21 +0100 Received: by hs-out-2122.google.com with SMTP id x43so4547434hsb.9 for ; Sun, 10 Feb 2008 09:46:20 -0800 (PST) Received: by 10.142.132.2 with SMTP id f2mr2746494wfd.221.1202665579889; Sun, 10 Feb 2008 09:46:19 -0800 (PST) Received: by 10.142.179.16 with HTTP; Sun, 10 Feb 2008 09:46:19 -0800 (PST) Message-ID: <71767b800802100946o4d465b79xad9b1f9515f7e69f@mail.gmail.com> Date: Sun, 10 Feb 2008 12:46:19 -0500 From: "Ralph Douglass" To: "Caml List" Subject: confusion about mutable strings MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_9427_23585184.1202665579884" X-Miltered: at discorde with ID 47AF386E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; mutable:01 toplevel:01 foo:01 printf:01 printf:01 val:01 foo:01 bug:01 toplevel:01 val:01 bug:01 ffff:98 ffff:98 strings:01 output:02 ------=_Part_9427_23585184.1202665579884 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 = # 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 ------=_Part_9427_23585184.1202665579884 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 ------=_Part_9427_23585184.1202665579884--