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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id C008DBC6B for ; Mon, 11 Feb 2008 11:02:02 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGCsr0fAXQImh2dsb2JhbACQOQEBAQgKKZJfg1I X-IronPort-AV: E=Sophos;i="4.25,332,1199660400"; d="scan'208";a="22461917" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Feb 2008 11:01:54 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m1BA1rUE006028 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 11 Feb 2008 11:01:53 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKurr0fRVYT2i2dsb2JhbACQOQEBAQgEBAkKEQWSYYNP X-IronPort-AV: E=Sophos;i="4.25,332,1199660400"; d="scan'208";a="9018956" Received: from an-out-0708.google.com ([209.85.132.246]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Feb 2008 11:01:52 +0100 Received: by an-out-0708.google.com with SMTP id c24so1041304ana.97 for ; Mon, 11 Feb 2008 02:01:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=BKutE2VrConftFf9ZRCB8mLIw2CVTf9Fg1zSvhf3wYc=; b=utR5HT2dyaFnTvfaISlyeJyquyIfxK9oc2TAaa7dGxw6qh47+e99hDXc7M2ZLghmRSf94SJ7XhOjvb+3AT3rWMA3OBP6mTfm3ZO9ZN8wHX3GXx6mZraBKoosGSFUTZmVNzO5l80aC/1sLAY0VXg0K847pWShBX50k63HL8vKeDg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uj21UFNwU2TADwTQLkc3iHVe+4NHH3HHQ+Gz8WG6aEV8iXX9npI80eQl1fkRrXt4HrNndOsObc0uw7MMyId3ICofn91YpSK3JVifl/PHc4jvGnFOiDv8Cbd2pGFPWPuYRftCbA1BysNj4DDGplH0GQJY+UMt8u+OZgrsei2Z0XI= Received: by 10.100.106.1 with SMTP id e1mr34105045anc.10.1202724111775; Mon, 11 Feb 2008 02:01:51 -0800 (PST) Received: by 10.100.248.15 with HTTP; Mon, 11 Feb 2008 02:01:51 -0800 (PST) Message-ID: <6f9f8f4a0802110201k5e81e65ft7dcbb9773be34f76@mail.gmail.com> Date: Mon, 11 Feb 2008 11:01:51 +0100 From: "Loup Vaillant" To: "Ralph Douglass" Subject: Re: [Caml-list] confusion about mutable strings Cc: "=?ISO-8859-1?Q?B=FCnzli_Daniel?=" , "Caml List" In-Reply-To: <71767b800802101622j45fd0db4id4351b44fb1f9cf3@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <71767b800802100946o4d465b79xad9b1f9515f7e69f@mail.gmail.com> <8BDAF65E-F29B-4F8C-B20E-1E0FDA521609@erratique.ch> <71767b800802101622j45fd0db4id4351b44fb1f9cf3@mail.gmail.com> X-Miltered: at discorde with ID 47B01D11.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; mutable:01 foo:01 iter:01 printf:01 printf:01 val:01 foo:01 ocaml:01 char:01 char:01 caml-list:01 strings:01 strings:01 unit:03 let:03 2008/2/11, Ralph Douglass : > > 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 = > # 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