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:26)
From: Alp Mestan <alp@m...>
Subject: Re: [Caml-list] Strings
On Sat, Apr 4, 2009 at 11:14 AM, David Rajchenbach-Teller <
David.Teller@ens-lyon.org> wrote:

> I personally can't remember the last time I've needed mutable strings in
> OCaml.

Neither do I.

> 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.

I think providing both capabilities is the best solution.
However, let's study Haskell's strings.
They simply are a list of characters. This let the ability to use heavily
list-related functions (take, takeWhile, drop, dropWhile, map, etc.). On the
other hand, OCaml's standard library lacks of many functions for strings ! I
think this is too much imperative oriented. Maybe we could try to implement
(for Batteries or in a separate project) string lists and then use the power
of Batteries' list module with many (really many... that's a real pleasure
to read its documentation) functions to work with. I think with a bit of
internal laziness, we could get a great immutable string type with many
functions to manipulate it.

But I guess there are many cons to do so, otherwise it would have been

Alp Mestan