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.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 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 04DD5BC6C for ; Sat, 19 Jan 2008 11:55:12 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEpmkUfRVYC/mGdsb2JhbACQFwEBAQEHBAYHChaVQ4du X-IronPort-AV: E=Sophos;i="4.25,220,1199660400"; d="scan'208";a="21499550" Received: from fk-out-0910.google.com ([209.85.128.191]) by mail4-smtp-sop.national.inria.fr with ESMTP; 19 Jan 2008 11:55:12 +0100 Received: by fk-out-0910.google.com with SMTP id b27so1081016fka.11 for ; Sat, 19 Jan 2008 02:55:12 -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:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=BGgaRc6aQMGTNgy/pXn3cjjQVc/W0nf05agc0ub76d8=; b=AimnRe6UAZVb/71RVk38pmny5tjlYM3XAA1oOekC9z8zBC2niKvIt9bqJXQiDpx2Q9Nh8CnvHM9ZBZWZy00cA+0xpnepOTlJ48eEzLlND2ySdeqPM+qAqAlSJafl1ljrHUlT42lQ43yMR0Wytx0Bx2KRvUECsY/GYsgp+EMWhCI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ms8a2X1qryCnHO/TIYnlXdEPRd2YWXIa5XFJxGiaWQqPUs1ZAyw/u8JCKm29KjRexmlrzUEsbqUmGXxf8XHrtccMDGAsZr7VNuOxCpTUBSIcju7/1BWlSAMqW+2IcNaL1PMI7v7PYtdEL69gBHuOF34Xi9nY7FT19BnJpo1+k3M= Received: by 10.78.132.2 with SMTP id f2mr6183316hud.44.1200740111980; Sat, 19 Jan 2008 02:55:11 -0800 (PST) Received: by 10.78.150.14 with HTTP; Sat, 19 Jan 2008 02:55:11 -0800 (PST) Message-ID: <53c655920801190255p71346ac9ka45adf0e1cef2d17@mail.gmail.com> Date: Sat, 19 Jan 2008 11:55:11 +0100 From: "David Baelde" Reply-To: david.baelde@ens-lyon.org To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Concatenation of static strings? In-Reply-To: <20080119143259.46752d11.mle+ocaml@mega-nerd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080119143259.46752d11.mle+ocaml@mega-nerd.com> X-Spam: no; 0.00; ocaml:01 bug:01 compiler:01 val:01 contrasted:01 arrays:01 mutable:01 statically:01 'l':01 statically:01 val:01 cheers:01 char:01 char:01 caml-list:01 Nice, I didn't know about the stripping of the first whitespaces. Speaking of static strings, the static string allocation done by OCaml is not compatible with the mutability of strings. I've been told that the issue was raised a long time ago, so I'm not filing this as a bug, but since I could not find any information on the web I thought someone here might be able to recall what motivated the decision in former discussions. Maybe the issue is considered a little price to pay for the optimization, since we rarely use string mutations.. The issue can be witnessed with the following code, on 3.10, either in the interactive loop or with any compiler: # let f () = let s = "bla" in let c = s.[0] in s.[0] <- 'c' ; c ;; val f : unit -> char = # f () ;; - : char = 'b' # f () ;; - : char = 'c' This is to be contrasted with arrays, which are mutable too but not statically allocated as for strings (let f () = let s = [|'b';'l';'a'|] in let c = s.(0) in s.(0) <- 'c' ; c). And for Erik, a test that tells us that concatenations are not done statically: # let f () = let s = "b"^"la" in let c = s.[0] in s.[0] <- 'c' ; c ;; val f : unit -> char = # f () ;; - : char = 'b' # f () ;; - : char = 'b' Cheers, David