English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: [Caml-list] Strings as arrays or lists...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-03-03 (08:50)
From: Luc Maranget <luc.maranget@i...>
Subject: Re: [Caml-list] Strings as arrays or lists...
> > > in Haskell, strings are lists of chars.
> > 
> > And what a horrible design decision that is!
> Agreed.  Well, it's a great way to multiply the memory requirements
> for your strings by a factor of 12 (on 32-bit platforms) or 24 (on
> 64-bit platforms), while at the same time losing constant-time
> indexing :-)  
> Actually, the list representation of strings is so repugnant that I
> don't even want to include "explode" and "implode" coercions between
> string and char list in the standard library.  A standard library
> should steer users away from algorithmically-inefficient code.  By not
> having implode and explode in the library, I hope OCaml programmers
> will come to the realization that the proper way to operate on strings
> is either via block operations (the String module, regexps, etc), or
> by recursion on integer indices.
> - Xavier Leroy

Xavier is right, of course.
However, in a lazy context, seeing strings as list of chars has some
advantages. This is not relevant to Caml anyway.


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