Browse thread
RE: [Caml-list] Re: immutable strings (Re: Array 4 MB size limit)
- Harrison, John R
[
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: | Harrison, John R <johnh@i...> |
| Subject: | RE: [Caml-list] Re: immutable strings (Re: Array 4 MB size limit) |
Hi Martin, | I disagree: has it ever happened to you to mutate a string by accident? The point is not that I will mutate a string by accident. I've never done it by accident or by design. The point is that I can't depend on code that I call, or code that calls mine, not to subsequently modify strings that are passed as arguments. So if I really need to reliably fix them I am forced into expensive copy operations. In practice, the obvious library calls are safe, so like Aleksey, I use the built-in strings for the sake of convenience and compatibility. But it's unsatisfactory intellectually. Some of us want to program in a primarily functional style, yet the implementation of one of the most basic and useful datatypes is not functional. | Yes, so how do you avoid copies without using the "unsafe" conversions all | over the place? With immutable strings, you'd never need to do conversions at the module interfaces. As with any other functional data structure, you only copy when you want to change part of it. John.