Version française
Home     About     Download     Resources     Contact us    
Browse thread
Strings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Rajchenbach-Teller <David.Teller@e...>
Subject: Re: [Caml-list] Strings

On Fri, 2009-04-03 at 12:56 +0100, Jon Harrop wrote:
> I read that batteries included provides first-class rope-based strings and I 
> was just reading up on some horror stories about immutable strings on 
> StackOverflow. This made me wonder what people's thoughts are about mutable 
> vs immutable strings?

Note that Batteries provides
* regular OCaml strings
* strings with capabilities (i.e. strings which, depending on their
type, can be read-only/write-only/read-write) -- sometimes faster than
regular strings, never slower
* immutable Unicode ropes.

I personally can't remember the last time I've needed mutable strings in
OCaml. On the other hand, I can remember a handful of times where, to
return a constant string, I had to make a function that would rebuild
the string at every call. Which is both needlessly slow and awkward for
what looks like a constant.

Cheers,
 David