On Saturday, 6 December 2014 at 16:10:20 UTC, Joseph Rushton
Wakeling via Digitalmars-d wrote:
On 05/12/14 23:03, deadalnix via Digitalmars-d wrote:
http://www.reddit.com/r/programming/comments/2ocmvb/stdstring_is_responsible_for_almost_half_of_all/

Looks like someone need immutable(char)[] .

Someone asked me the other day, and I realized I didn't have a ready answer as I'd never particularly considered it: why is it important/beneficial that the string type be immutable(char)[] ?

Because string literals must be in the read only part of the
program.
----

void test()
{
     string s="abc";
     callFunc(s);
     s[0]='z'//next call to test will set a="zbc"
}

----
Otherwise the compiler would have to create a copy everytime you
assign a string literal to variable(call .dub for you).

Reply via email to