Browse thread
Strings
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Kuba Ober <ober.14@o...> |
| Subject: | Re: [Caml-list] Strings |
On Apr 3, 2009, at 1:50 PM, Daniel Bünzli wrote: > Le 3 avr. 09 à 18:52, Martin Jambon a écrit : >> - I see absolutely no practical advantage of having an immutable >> "character >> string" type. > > 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. Or maybe OCaml should have an immutable string wrapper that can be created from a mutable string? Such immutable strings would be returned where the string is not supposed to be further modified. That's where I like C++/Qt copy-on-write strings a lot. They make life easy. Cheers, Kuba