From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 1CB31BC88 for ; Fri, 11 Feb 2005 03:05:47 +0100 (CET) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1B25k5h001784 for ; Fri, 11 Feb 2005 03:05:46 +0100 Received: by wproxy.gmail.com with SMTP id 71so561351wra for ; Thu, 10 Feb 2005 18:05:46 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=ZLOp1U9ns2jJ8HlfaQpXfxEPYQlCrvFYPDZTl1adOZpcn78sKWOuZYmIpkQiA2e7R+Lts20u1qqzvaVYExvmzLWUGWZPsNgKD1BoprFpW3OZNMahqM/+8kaQ2orCOOr2DN3UZJMTlxmA9mu+P1RSCZUblKC+6nSMh5pdePVRDyI= Received: by 10.54.23.13 with SMTP id 13mr27685wrw; Thu, 10 Feb 2005 18:05:43 -0800 (PST) Received: by 10.54.22.12 with HTTP; Thu, 10 Feb 2005 18:05:42 -0800 (PST) Message-ID: Date: Thu, 10 Feb 2005 21:05:42 -0500 From: John Prevost Reply-To: John Prevost To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] String to list to string In-Reply-To: <1108084921.16698.213.camel@pelican.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <012676D607FCF54E986746512C22CE7D02DF7754@orsmsx407> <200502101928.26511.jon@jdh30.plus.com> <1108084921.16698.213.camel@pelican.wigram> X-Miltered: at nez-perce with ID 420C12FA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; prevost:01 prevost:01 caml-list:01 sourceforge:01 wrote:01 buffer:01 buffer:01 mutable:01 mutable:01 datatype:01 caml's:01 annotation:01 datatype:01 mutation:01 unboxing:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.2 X-Spam-Level: On Thu, 10 Feb 2005 17:32:18 -0800 (PST), skaller wrote: > Throws out transparency/persistence and fails to > allow any length changing operations, which are > common for strings -- overwriting strings is rarely > needed. The only use I can think of is as a buffer > (and we have Buffer module for that, and it > also allows variable length) As much as I hate to agree with skaller, I do agree here. :) Having the only kind of strings be mutable strings (like this, with each point in the string being mutable, but not other attributes) is painful. I *do* think that having a natively supported type for these "octet buffers" is handy, especially when doing IO. But most of the time, I want something else. One way to think about why it's irritating for me is that by far the *easiest* things to point to for "reasons the ML type system is really helpful" are refs and options. Because the default behavior is that everything is immutable, but refs are simple and easy to use, we have the option in ML to choose whether our datatype should be mutable or not. (Extend that somewhat to include Caml's mutable annotation, which I think is acceptable.) Likewise, by default every value must be given, but options give us the ability to provide a kind of "null" value. (And if we wish to define our own datatype, we can distinguish different types of null--N/A vs. unknown, for a basic example.) But the way Caml strings are done forces us to deal with the fact that every string is mutable--we don't have the option of making a string that isn't. If we want to, we can package things up to prevent this--providing a way to box up a string into an immutable string (make a copy, prevent mutation using the type system). But then we can't use the standard library without unboxing (making another copy) to get a "normal" string value out. This isn't the end of the world, of course. But it is a wart that I periodically meditate on. John.