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 09776BB84 for ; Wed, 31 May 2006 14:53:26 +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 k4VCrO10007757 for ; Wed, 31 May 2006 14:53:25 +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 OAA19780 for ; Wed, 31 May 2006 14:53:24 +0200 (MET DST) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k4VCrO2D003311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 31 May 2006 14:53:24 +0200 Received: from smtp.lri.fr (serveur3-5 [129.175.3.5]) by ext.lri.fr (Postfix) with ESMTP id C7703202147; Wed, 31 May 2006 14:53:23 +0200 (CEST) Received: from pc9-152.lri.fr (pc9-152 [129.175.9.152]) by smtp.lri.fr (Postfix) with ESMTP id 4CA82CED98; Wed, 31 May 2006 14:53:22 +0200 (CEST) Received: from filliatr by pc9-152.lri.fr with local (Exim 4.52) id 1FlQCf-0004Gz-Pq; Wed, 31 May 2006 14:53:37 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <17533.37329.744780.371184@pc9-152.lri.fr> Date: Wed, 31 May 2006 14:53:37 +0200 To: "Harrison, John R" Cc: "Martin Jambon" , "Caml List" Subject: RE: [Caml-list] Re: immutable strings (Re: Array 4 MB size limit) In-Reply-To: <196F1D996F92CD46A542EA519DB8CE4703CCA9F0@orsmsx409> References: <196F1D996F92CD46A542EA519DB8CE4703CCA9F0@orsmsx409> X-Mailer: VM 7.19 under Emacs 21.4.1 From: Jean-Christophe Filliatre X-Virus-Scanned: by amavisd-new at lri.fr X-Miltered: at concorde with ID 447D91C4.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 447D91C4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; filliatre:01 filliatr:01 lri:01 bug:01 coq:01 capitalized:01 coq:01 hash-consing:01 speedup:01 filliatre:01 lri:01 filliatr:01 writes:01 caml-list:01 abstract: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 Harrison, John R writes: > The point is not that I will mutate a string by accident. I once discovered a bug in the Coq proof assistant that was precisely due to a string (an identifier) mutated by accident (may be I shouldn't say it :-) A name was capitalized in-place somewhere in a piece of code unrelated with the Coq kernel but of course it had consequences all over the system (including the kernel). So I'm definitely in favor of immutable strings, for the exact reasons mentioned by John. But I think an abstract data type is not really an issue, since one does little pattern-matching on strings in practice. And having your own abstract data type for immutable strings has other advantages, such as the ability to share equal strings (using hash-consing) to speedup names comparisons. Even printing is not painful provided a suitable formatter-based printing function and %a. -- Jean-Christophe Filliātre (http://www.lri.fr/~filliatr)