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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 35776BB83 for ; Thu, 25 May 2006 21:28:41 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4PJSeB7011897 for ; Thu, 25 May 2006 21:28:40 +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 VAA15842 for ; Thu, 25 May 2006 21:28:40 +0200 (MET DST) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4PJSd5p011893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 25 May 2006 21:28:40 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from first.in-berlin.de (e178020133.adsl.alicedsl.de [85.178.20.133]) (authenticated bits=0) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id k4PJSX80007728 for ; Thu, 25 May 2006 21:28:33 +0200 Received: by first.in-berlin.de (Postfix, from userid 501) id 5518D2940D4; Thu, 25 May 2006 21:28:32 +0200 (CEST) Date: Thu, 25 May 2006 21:28:31 +0200 From: Oliver Bandel To: caml-list@inria.fr Subject: Re: [Caml-list] Re: immutable strings (Re: Array 4 MB size limit) Message-ID: <20060525192831.GA452@first.in-berlin.de> 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> <77959C0C-D878-412A-A1A3-3C9D382EDB93@conjury.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <77959C0C-D878-412A-A1A3-3C9D382EDB93@conjury.org> User-Agent: Mutt/1.5.6i X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at nez-perce with ID 44760568.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44760567.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 woodyatt:01 mutable:01 trivial:01 runtime:01 mutable:01 variants:01 mutation:01 runtime:01 compiler:01 debugging:01 ocaml:01 debugging:01 compilers: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.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Thu, May 25, 2006 at 12:23:51AM -0700, j h woodyatt wrote: > On May 24, 2006, at 10:56 PM, Martin Jambon wrote: > > > >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. > > I have no dog in this fight, but I can imagine a pragmatic approach > that might satisfy some of these concerns without introducing much in > the way of extra runtime complexity costs. > > Change the way strings are boxed so that there is an additional tag > for immutable strings as opposed to the normal mutable ones. In all > respects, allow string objects with either tag to be treated the same > by functions that do not modify the content of the string. When the > "safe" variants of the string mutation functions are called on a > string object with the immutable tag, throw a runtime exception. [...] Compiletime error would be what I would prefer. [...] > It *might* > give a pragmatic benefit of surfacing unintentional programming > errors earlier than they might otherwise be found, [...] The earlier the better it is. It's like non-matching types found by the compiler: it helps a lot in development. Debugging normallay takes the most time in development; and with OCaml debugging time decreases much - that is what I experienced. And this comes from early getting a hint to possible problems (possible with compilers that would accept such code; im possible when the compiler says: "no! I don't accept these sources!"). Ciao, Oliver