April 04, 2005
Why can CONSTANT arrays be sorted and modified at runtime?
Is this a bug?

 <code>

int main(char[][] args)
{
    const char[][] ABCD = [ "DDD", "AAA", "CCC", "BBB"];

    ABCD.sort;        // No error!

    ABCD[3]="333";    // No error too!

    ABCD.reverse;     // Also no error!

    foreach(inout char[] String; ABCD)
    writef(String,'\n');

    return 0;
};

 </code>

Maybe only the struct (that contains the pointer to the data and the length of the array) is constant, because adding strings (ABCD ~= "EEE") is not allowed. But how can I then make the data constant?

( DMD 0.119 )

Florian