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=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 208D0BC0A for ; Sat, 16 Jun 2007 19:01:32 +0200 (CEST) Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [203.16.214.135]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5GH1TaA032559 for ; Sat, 16 Jun 2007 19:01:31 +0200 X-IronPort-AV: E=Sophos;i="4.16,430,1175437800"; d="scan'208";a="103846184" Received: from ppp2-129.lns1.syd7.internode.on.net (HELO [192.168.1.201]) ([59.167.2.129]) by ipmail03.adl2.internode.on.net with ESMTP; 17 Jun 2007 02:31:25 +0930 Subject: Re: [Caml-list] Not really a bug but... From: skaller To: Loup Vaillant Cc: caml-list@yquem.inria.fr In-Reply-To: <6f9f8f4a0706160310m285f0b63r7e2087a31ae46671@mail.gmail.com> References: <200706160117.45971.jon@ffconsultancy.com> <46739188.5060605@inria.fr> <6f9f8f4a0706160310m285f0b63r7e2087a31ae46671@mail.gmail.com> Content-Type: text/plain Date: Sun, 17 Jun 2007 03:01:21 +1000 Message-Id: <1182013281.553.13.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46741769.004 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bug:01 0200,:01 frisch:01 frisch:01 semantics:01 literals:01 literals:01 abstractions:01 ocaml:01 mutable:01 mutable:01 ocaml:01 sourceforge:01 garbage:01 wrote:01 On Sat, 2007-06-16 at 12:10 +0200, Loup Vaillant wrote: > 2007/6/16, Alain Frisch : > > Jon Harrop wrote: > > > Any chance of changing the semantics of string literals so they aren't static? > > [...] > > If it were done automatically, there would be a penalty for > > the common case of immutable strings; to avoid it, you'd need to lift > > constant literals out of abstractions, which is not very nice. > > By the way, why Ocaml didn't take the Java path, i.e. making truly > immutable strings, And provide mutable string buffers as well? It didn't because it didn't .. :) Strings are mutable because they can be, without impacting the run time/garbage collector: Ocam's razor says use one type when it will do the work of two. It's unfortunate that in the abstract, Ocaml string are entirely the worst possible multi-function data type as a result, since they neither offer the advantages of immutability nor the advantages of being variable length: mutable fixed length strings are almost useless .. but not entirely: they're still useful as I/O buffers. -- John Skaller Felix, successor to C++: http://felix.sf.net