From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 92D8EBC88 for ; Thu, 10 Feb 2005 20:26:44 +0100 (CET) Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j1AJQifr012400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 10 Feb 2005 20:26:44 +0100 Received: from [80.229.56.224] (helo=chetara) by ptb-relay02.plus.net with esmtp (Exim) id 1CzJxZ-000B2J-Tf for caml-list@yquem.inria.fr; Thu, 10 Feb 2005 19:26:42 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] String to list to string Date: Thu, 10 Feb 2005 19:28:26 +0000 User-Agent: KMail/1.7.1 References: <012676D607FCF54E986746512C22CE7D02DF7754@orsmsx407> In-Reply-To: <012676D607FCF54E986746512C22CE7D02DF7754@orsmsx407> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200502101928.26511.jon@jdh30.plus.com> X-Miltered: at concorde with ID 420BB574.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 ocaml's:01 mutable:01 ocaml:01 ocaml:01 char:01 vastly:01 subjective:01 char:01 compilers:01 binary:01 statically:01 imho:01 usefulness: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=none autolearn=disabled version=3.0.2 X-Spam-Level: On Thursday 10 February 2005 18:35, Harrison, John R wrote: > ...I consider OCaml's mutable strings a far worse design error. That's interesting. Why? I appreciate ocaml allowing me to write efficient code for all sorts of things when I need to. I would be very miffed if the language enforced an inefficient style upon me. If ocaml used char lists then you have vastly different complexities for a variety of important operations. Which of these operations is most important is subjective, of course. If ocaml used an immutable char array then you would need quite a bit more in the compilers to get decent performance. If ocaml used a balanced binary tree then the pattern matcher would need to know about this kind of data structure and the asymptotic complexity of pattern matching would go from O(1) to O(ln n) for some leaf patterns. Having said that, I have been bitten by some oddities (e.g. statically allocated string constants) but this seems like a small price to pay for the expressiveness of an impure functional language, IMHO. I suppose you could have "abcd" patterns over the type "char list" instead of "string" whilst keeping the string type. Do many programs/functions use both string patterns and the mutability of the string type? Of course, the usefulness of the current string type would be much more clear-cut in the presence of Richard Jones' style "abcd".. | .."dcba" prefix/suffix patterns as the latter can't be done on lists in O(m) (where "n" is the number of chars in the matched string and "m" is the number of chars in the string appearing in the pattern). -- Dr Jon D Harrop, Flying Frog Consultancy Ltd.