const issues and more!
Saaa
empty at needmail.com
Mon Jan 14 12:55:08 PST 2008
:)> Will this work as well?
int[] def = [ 1, 2, 3 ];
def[0]=0;
int[] def2 = [ 1, 2, 3 ];
assert(def2[0..2] == [ 0, 2, 3 ]);
>> to compile, then you are free to modify the constant "text"! For
>> example, in D 1.0 this works:
>>
>> char[] text = "text";
>> text[0] = 'n';
>> char[] text2 = "text";
>> assert(text2 == "next");
>>
>> These kinds of errors are subtle and hard to find. This is why you are
>> not allowed to have a non-const or invariant pointer to invariant data
>> such as string literals.
>>
>> -Steve
>>
>
>
More information about the Digitalmars-d
mailing list