Sorry, I was indeed informed today by someone at work that it was talked about a week or two ago. There is so much going on on the list that I just missed it. And now I added noise myself. Sigh.
Thanks,
Ralph
2008/2/11, Ralph Douglass <ralph@grayskies.net>:
>
> Observe the following:
>
> # let foo () =
> let bar = [|'a';'b';'c'|] in
> Array.iter (Printf.printf "%c") bar;
> bar.(0) <- 'd';
> bar;;
> val foo : unit -> char array = <fun>
> # foo ();;
> abc- : char array = [|'d'; 'b'; 'c'|]
> # foo ();;
> abc- : char array = [|'d'; 'b'; 'c'|]
>
> Why does OCaml treat these two examples in such a different manner? Is
> there a reason why strings are magically special in this way?
C strings are usually "magically special" in exactly the same way. It
has been talked about in another thread (dunno how to look for it).
Basically, this is a design choice meant for better performance.
Loup