From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA08042; Mon, 3 Mar 2003 19:25:08 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 TAA08177 for ; Mon, 3 Mar 2003 19:25:05 +0100 (MET) Received: from hirsch.in-berlin.de (hirsch.in-berlin.de [192.109.42.6]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h23IP4H16919 for ; Mon, 3 Mar 2003 19:25:05 +0100 (MET) Received: from hirsch.in-berlin.de (localhost [127.0.0.1]) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with ESMTP id h23IP4EG008103 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT) for ; Mon, 3 Mar 2003 19:25:04 +0100 Received: from first.UUCP (uucp@localhost) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with UUCP id h23IP4L6008101 for inria.fr!caml-list; Mon, 3 Mar 2003 19:25:04 +0100 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: inria.fr!caml-list Received: by first.in-berlin.de via sendmail from stdin id (Debian Smail3.2.0.114) Mon, 3 Mar 2003 19:28:06 +0100 (CET) From: oliver@first.in-berlin.de (Oliver Bandel) Date: Mon, 3 Mar 2003 19:28:06 +0100 To: caml-list@inria.fr Subject: [oliver: Re: [Caml-list] Strings as arrays or lists...] Message-ID: <20030303182806.GC624@first.in-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Spam: no; 0.00; oliver:01 in-berlin:01 bandel:01 caml-list:01 brogoff:01 demonstrate:01 char:01 abstraction:01 implemented:01 stdlib:01 basement:99 programmer's:01 arrays:01 ocaml:01 speakeasy:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk ooops, forgotten to Cc: to the list. Ciao, Oliver ----- Forwarded message from oliver ----- To: brogoff@speakeasy.net Subject: Re: [Caml-list] Strings as arrays or lists... On Mon, Mar 03, 2003 at 09:12:32AM -0800, brogoff@speakeasy.net wrote: > Yes, Xavier is right here, and I apologize for posting an "explode" function > on this list. I'll appeal for leniency, mentioning that I didn't post > "implode", and that I only posted the former function to demonstrate that > it could be done, and to point out that one of the many reasons strings as > char lists is wrong as a basic type is that you get an abstraction inversion. What is an abstraction inversion? Sounds very interesting, but I don't understand, waht this means. What I first have written about the string-stuff, was: It's not FP-like, but I also would be happy with a syntax, that would allow me, to use Array-functions for the Strings. If there maybe is a typing-reason, why not strings AND arrays should have same syntax ( e.g. both .[index] or both .(index) ) then maybe it would be possible to add the typical Array-functions (or List-functions) to the String-Library? Why not converting a string to a list with String.to_list or to an array with String.to_array Arrays can be converted with Array.to_list (or vice versa with Array.of_list). Why not such stuff for strings? If they are already array-like, why not using such functions? Why not using a String.map for application of char-based functions to each char? To write more abstract String-manipulation is also ok, so that the char-wise stuff would be on a lower level (inside the library, maybe implemented in C or is some imperative Ocaml-stuff, which the user of the library does not see). OK, strings are not char-lists, and they are not char-arrays. At least not to the user. But it would help, to have such powerful functions like .map .iter .fold_left .fold_right .filter Where Module here would be one of: Array, List, String. If this is not very senseful, because the functions are only applied to char#s and not to any type ('a) (like in Array- or List-module), and this powerful functions are bored, when used only at one type (char), then it would make sense to have at least these two functions in the Array.module: Array.to_string Array.of_string If you think, this is not necessary in the stdlib, because it is easy to convert strings to arrays (very similar notation/syntax), then I can answer: Well, it is also easy to implement functions like Array.to_list Array.of_list So why having them in the stdlib? If there are conversion-functions between the fundamental data-types (Array.to_list, Array.of_list, string_of_int, string_of_float, int_of_string, int_of_float) why are there no conversions between (at least) string and Array? Ciao, Oliver P.S.: Another thing, where I think about, is: Shouldn't it be possible to handle strings as Lists for the user, even if it is implemented array-based somewhere deep in the basement of the code-base? So, that it would be possible to handle strings like [char], even if they are implemented array-based (and therefore perfromant)? Isn't one of the major goals of Languages like Ocaml, to have a clear distinction between implementation and interface? (Or does your "abstraction inversion" here says "No!" to such a thing?) P.P.S.: The reason, why I asked for R-Tree/R+-Tree/Quad-Tree- Implementation in Ocaml: They are very good tools for *very* highlevel textprocessing. So maybe some Tree-libraries would be a good thing for Ocaml, but IMHO such stuff is better suited on a COAN, and should not be part of the Ocaml-language/-standard- libraries itself. But it's good to have such libraries too, even if it should be relatively easy to implement it in Ocaml. I think, when some OCaml-gurus would implement them, they would be more performant and easy to use, than if any other Ocaml-programmer would write his/her own solution. And such basic (often called) stuff should be performant... ----- End forwarded message ----- -- Why Ocaml is programmer's heaven? http://www.win.tue.nl/~lhol/projects/pargen/ocaml.html ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners