From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 755B4BB83 for ; Thu, 25 May 2006 08:00:54 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4P60rLr021469 for ; Thu, 25 May 2006 08:00:53 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA04035 for ; Thu, 25 May 2006 08:00:53 +0200 (MET DST) Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com [66.111.4.27]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4P60q2h002062 for ; Thu, 25 May 2006 08:00:52 +0200 Received: from frontend3.internal (frontend3.internal [10.202.2.152]) by frontend1.messagingengine.com (Postfix) with ESMTP id C1B54D6830A; Thu, 25 May 2006 02:00:51 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by frontend3.internal (MEProxy); Thu, 25 May 2006 02:00:51 -0400 X-Sasl-enc: uPGrz+a6bqsJo5u7y/eDOqmWoItglTviRtrSaJZrFVe2 1148536849 Received: from [172.16.13.143] (burnham.ljcrf.edu [192.231.106.2]) by mail.messagingengine.com (Postfix) with ESMTP id F0F8F502A; Thu, 25 May 2006 02:00:48 -0400 (EDT) Date: Wed, 24 May 2006 22:56:35 -0700 (PDT) From: Martin Jambon X-X-Sender: martin@droopy To: Stefan Monnier Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: immutable strings (Re: Array 4 MB size limit) In-Reply-To: Message-ID: References: <20060515141230.ajyupn2z28k0484s@horde.akalin.cx> <446D5E4A.8060005@akalin.cx> <20060519162844.GA32550@osiris.uid0.sk> <200605192226.34917.jon@ffconsultancy.com> <20060520211117.GA2670@first.in-berlin.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 44754815.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44754814.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; mutable:01 mutable:01 byte:01 arrays:01 ocaml:01 byte:01 arrays:01 trivial:01 wrote:01 caml-list:01 imho:01 signatures:01 immutable:01 immutable:01 strings:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thu, 25 May 2006, Stefan Monnier wrote: >> IMHO strings should be possibly made immutable by using the "immutable" >> keyword, which is the opposite of the "mutable" keyword as it is used for >> records. So the user/programmer can chose the kind of strings he7she wants. > > I think it's OK to have (mutable) byte arrays, but strings should simply > always be immutable. OCaml strings are compact byte arrays which serve their purpose well. Having a whole different type for immutable strings is in my opinion a waste of energy. The problem is that freezing or unfreezing a string safely involves a copy of the whole string. And obviously it's not possible to handle only immutable strings since somehow you have to create them, and unlike record fields, they won't be set in one operation but in n operations, n being the length of the string. So I'd really love to see actual examples where using immutable strings would be such an improvement over mutable strings. If the problem is just to ensure that string data won't be changed by the user of a library, then it is trivial using module signatures and String.copy for the conversions. Martin -- Martin Jambon, PhD http://martin.jambon.free.fr Edit http://wikiomics.org, bioinformatics wiki