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
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-04-04 (09:13)
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.