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: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Strings
On Saturday 04 April 2009 18:11:20 Kuba Ober wrote:
> On Apr 3, 2009, at 1:50 PM, Daniel Bünzli wrote:
> > In fact I find the result of the following sequence of operations
> > very disappointing for a functional programming language :
> >
> >        Objective Caml version 3.11.0
> >
> > # Sys.os_type;;
> > - : string = "Unix"
> > # let s = Sys.os_type;;
> > val s : string = "Unix"
> > # s.[0] <- 'a';;
> > - : unit = ()
> > # Sys.os_type;;
> > - : string = "anix"
>
> Perhaps mutable data of any type should be markable as const, with the
> marking being permanent.

Would a phantom type parameter be sufficient:

  [`RO|`RW] string

> That's where I like C++/Qt copy-on-write strings a lot. They make life
> easy.

Just as long as they don't copy the entire string when I mutate a single char!

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e