From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id E8A26BBC4 for ; Sat, 4 Apr 2009 23:51:51 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqIDACNz10nZSMDjZmdsb2JhbACBUZRUDQsDBQkPBbQchA8G X-IronPort-AV: E=Sophos;i="4.39,324,1235948400"; d="scan'208";a="25644212" Received: from fmmailgate02.web.de ([217.72.192.227]) by mail3-smtp-sop.national.inria.fr with ESMTP; 04 Apr 2009 23:51:51 +0200 Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate02.web.de (Postfix) with ESMTP id 15237FC7D36C; Sat, 4 Apr 2009 23:51:51 +0200 (CEST) Received: from [78.43.226.218] (helo=frosties.localdomain) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #277) id 1LqDmI-0002u7-00; Sat, 04 Apr 2009 23:51:51 +0200 Received: from mrvn by frosties.localdomain with local (Exim 4.69) (envelope-from ) id 1LqDmI-0002Sm-J7; Sat, 04 Apr 2009 23:51:50 +0200 From: Goswin von Brederlow To: Alp Mestan Cc: David Rajchenbach-Teller , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Strings References: <200904031256.33357.jon@ffconsultancy.com> <1238836474.6250.11.camel@Blefuscu> Date: Sat, 04 Apr 2009 23:51:50 +0200 In-Reply-To: (Alp Mestan's message of "Sat, 4 Apr 2009 11:26:46 +0200") Message-ID: <87ocvc6qa1.fsf@frosties.localdomain> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.21 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX1/sUzsG6Nz1eQxIcxFj2nKgHZ/sPOP4AUFszXK9 6/+eYLTSNiKC4bOA1opEGUTx8tXpehp5YqSUKqfmI9xcoB6Zrw 4/khLNCC0= X-Spam: no; 0.00; haskell's:01 ocaml:01 ocaml:01 ocaml's:01 lacks:01 mutable:01 arrays:01 lib:01 arrays:01 blit:01 mfg:98 char:01 char:01 caml-list:01 functions:01 Alp Mestan writes: > I think providing both capabilities is the best solution. Phantom types solvethis beautifully with not truntime penalty. GO BATTERIES! > However, let's study Haskell's strings. > They simply are a list of characters. This let the ability to use heavily > list-related functions (take, takeWhile, drop, dropWhile, map, etc.). On the The beauty of ocaml strings is that they are really compact. An ocaml string on 32bit is 5-8 bytes longer than the contained string and 9-16 bytes on 64bit. On the other hand a list of characters is 8/16 times as large. Not to mention that you have no random access. > other hand, OCaml's standard library lacks of many functions for strings ! I > think this is too much imperative oriented. Maybe we could try to implement > (for Batteries or in a separate project) string lists and then use the power > of Batteries' list module with many (really many... that's a real pleasure to > read its documentation) functions to work with. I think with a bit of internal > laziness, we could get a great immutable string type with many functions to > manipulate it. > But I guess there are many cons to do so, otherwise it would have been > "standardized". Mutable/Immutable can really nicely done with phantom types and is independent of the data structure used. It works for strings, lists, arrays, sets, trees, ... and I think all standard modules should have it. The official standard lib is rather lacking there but that is why there is Batteries. The more I hear/see of it the more I like it. As for char lists for strings you can always convert strings to char lists when that is a better representation. I've done so myself on a number of ocasions. But just as often I used strings as char arrays. Doing e.g. String.blit with char lists would be ugly. MfG Goswin