On Tue, Apr 28, 2009 at 6:07 PM, MLT <n...@anon.com> wrote: > 2. char[] vs. int[] > I think it is strange that > char[] x = "1234" ; > x[0] = '4' ; > > Produces a run time error, but > int[] x = [1,2,3,4] ; > x[0] = 4 ; > Doesn't. I think that they both should, or both shouldn't - to be consistent > (and it would be better if they both didn't). Best would be again, to allow > the programmer to specify where the array (or other stuff) should be stored. >
It pretty much boils down to this (mostly said in other replies) * string literals are special, they are allocated in a static data segment, readonly if the platform allows it. * arrayliterals as non-static expressions are always heap allocated. even when there's absolute no need for it... (see http://d.puremagic.com/issues/show_bug.cgi?id=2356 ) -Tomas