On Tuesday, 2 July 2013 at 09:10:33 UTC, Michal Minich wrote:
void main ()
{
    char[] str = "abc";
    // Error: cannot implicitly convert expression ("abc")
    // of type string to char[]
}

I thought there is no harm in that?

char[] str = ['a', 'b', 'c'];

This will only allocate once without placing data in object file. This is caused by obsolete Cism moved into modern language to treat string literals as constant objects (perhaps reasoning was made in 1980s in memory constraints of those times).

Ideally char[] str = "abc" should be as normal as int[] arr = [0,1,2] allowing to play with data as much as you wish.

Reply via email to