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-06 (11:02)
From: Zheng Li <zheng_li@u...>
Subject: Re: Strings
On 4/6/2009 11:20 AM, David Rajchenbach-Teller wrote:
> 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.

Fair enough. But then users of the library still have to hard copy a 
batteries string to ensure it won't change in the future (which is the 
starting topic of the this thread).

> That's by design: [to_string] is the identity operation and it only
> applies to strings for which you have both read and write capabilities.
> If you wish to do what I believe you have in mind, you need to first
> [copy] the string.


>> The compiler simply doesn't
>> allow me to print out a read-only string, nor does it allow many
>> reasonable things like<<join ro"asdf" ro"jkl">>  etc.
> Er, how can you "not print out a read-only string"?
> And for your [join] problem, well, works for me (as soon as you remember
> that it takes as second argument a *list* of readable strings).
> # print stdout (join ro";" [ro"1"; ro"2"; ro"3"]);;
> 1;2;3- : unit

My mistake.