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
[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: -- (:)
From: Xavier Leroy <xavier.leroy@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

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: