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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Goswin von Brederlow <goswin-v-b@w...>
Subject: Re: Strings
David Rajchenbach-Teller <> writes:

> On Sun, 2009-04-05 at 12:06 +0200, Zheng Li wrote: 
>> With phantom type alone, the abstraction can still leak.
> Ok, it's actually not *immutable* strings but *read-only* strings. The
> objective is to be able to distribute a text and make sure that the
> client won't be able to modify it. The original owner can still decide
> to enter "mutable-land" if they need it.

Maybe there should be another capability `Const that can only be
gained when creating/copying a string.

let make_const : 'a string -> [`Const; `Read] string = String.copy

Those would be truely immutable. The use would be for strings passed
to libraries that the library wants to ensure are immutable so it can
avoid copying them.