Immutable immutable strings??

Marco Leise Marco.Leise at gmx.de
Fri Feb 10 10:10:48 PST 2012


Am 10.02.2012, 19:07 Uhr, schrieb H. S. Teoh <hsteoh at quickfur.ath.cx>:

> I'm not sure whether the following a compiler/language bug or a Phobos
> bug, but it's definitely some kind of bug:
>
> 	auto s = "abc";
> 	immutable t = "def";
>
> 	writeln(typeid(s));	// immutable(char)[]
> 	writeln(typeid(t));	// immutable(immutable(char)[])
> 				// (what is this supposed to mean?!)

That is supposed to mean that you can neither modify the values of the  
characters in the array nor the array itself:

t[1] = 'a'; // immutable(char)
t.length = 2; // immutable(...[])


More information about the Digitalmars-d-learn mailing list