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 B851EBC88 for ; Thu, 10 Feb 2005 20:32:26 +0100 (CET) Received: from mail26.sea5.speakeasy.net (mail26.sea5.speakeasy.net [69.17.117.28]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1AJWOX6025251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 10 Feb 2005 20:32:26 +0100 Received: (qmail 29681 invoked from network); 10 Feb 2005 19:32:22 -0000 Received: from shell3.sea5.speakeasy.net ([69.17.116.4]) (envelope-sender ) by mail26.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 10 Feb 2005 19:32:22 -0000 Date: Thu, 10 Feb 2005 11:32:22 -0800 (PST) From: brogoff To: "Harrison, John R" Cc: caml-list@yquem.inria.fr Subject: RE: [Caml-list] String to list to string In-Reply-To: <012676D607FCF54E986746512C22CE7D02DF7754@orsmsx407> Message-ID: References: <012676D607FCF54E986746512C22CE7D02DF7754@orsmsx407> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 420BB6C8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 haskell:01 categorical:01 ocaml's:01 mutable:01 weis:01 mutable:01 arrays:01 lazy:01 suffices:01 overloading:01 ocaml:01 categorical:01 substrings:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.8 required=5.0 tests=SPF_SOFTFAIL autolearn=disabled version=3.0.2 X-Spam-Level: On Thu, 10 Feb 2005, Harrison, John R wrote: > | > Haskell treats strings as lists of chars by default. > | > | Just goes to show you that even really smart people can do some > amazingly > | dumb things. > > That's far too categorical; opinions differ on this subject. > I'd be > quite > happy with strings as lists of characters, and I consider OCaml's > mutable > strings a far worse design error. I disagree. Given strings as lists, or even something not as ridiculous, like ropes (which Pierre Weis said existed in an older Caml) the programmer can not write an efficient mutable string over it. And, mutability aside, string algorithms usually view strings as arrays, not lists. At least the other lazy language gets this right. You would penalize almost all nontrivial string manipulation programs if we fixed this "design error" with the approach you find less odious. IMO, the problem is that no one string (or array) type suffices for all or even most purposes, and without some kind of overloading, having say five or six different string types becomes notationally heavy. So, while I'd love to have immutable strings, if there is going to be just one privileged string type in OCaml, I think mutable strings are a reasonable choice, not an error. Error is far too categorical. > And yes, I use "implode" and "explode" all the time, Have you no shame, to broadcast these perversions in a group which may have young programmers? Really! ;-) > because lists of > characters are often simple and convenient to deal with in a functional > style, and string manipulations are almost never performance-critical > in the kind of code I write. And you can (but shouldn't!) write those functions in your sleep in a few lines of ML, over the existing mutable strings. My preference for functional string processing is, as I said, substrings. They are convenient, and encapsulate the index manipulations in the data type. I'm almost certain you've seen them, what's your issue? -- Brian