On Wed 04 Jan 2012 09:29, Mike Gran <spk...@yahoo.com> writes: > char y[6] = "hello"; > > C provides a way to create and initialize a mutable string.
This one is more like (define y (string #\h #\e #\l #\l #\o)) just like (define y (list #\h #\e #\l #\l #\o)) (define y (vector #\h #\e #\l #\l #\o)) etc. > It all depends on your mental model. Your saying that (define y "hello") > attaches "hello" to y, and since "hello" is a immutable, the string y > contains must be immutable. This is what the Scheme standard says, yes. > This is an argument based on purity, not utility. You don't think optimizations are of any use, then? :-) Immutable literals allows literals to be coalesced, leading to the impressive 2x speed improvements in Dorodango startup time, some months back. > It was wrong to change this without deprecating it first. I am not certain that is the case. Mutating string literals has always been an error in Scheme. It did "work" with Guile 1.8 and before; but since 1.9.0 when the compiler was introduced and started coalescing literals, it has had the possibility to cause bugs. The changes in 2.0.1 prevented those bugs by marking those strings as immutable. I was going to propose a workaround with an option to change vm-i-loader.c:43 and vm-i-loader.c:115 to use a scm_i_mutable_string_literals_p instead of 1, but that really seems like the path to perdition: previously compiled modules would start creating mutable strings where they really shouldn't. We could add a compiler option to turn string literals into (string-copy FOO). Perhaps that's the thing to do. Andy -- http://wingolog.org/