Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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 Archives:
Bug reports: FAQ:
Beginner's list: