string types: const(char)[] and cstring

janderson askme at me.com
Sat May 26 15:25:21 PDT 2007


Walter Bright wrote:
> Under the new const/invariant/final regime, what are strings going to be 
> ? Experience with other languages suggest that strings should be 
> immutable. To express an array of const chars, one would write:
> 
>     const(char)[]
> 
> but while that's clear, it doesn't just flow off the keyboard. Strings 
> are so common this needs an alias, so:
> 
>     alias const(char)[] cstring;
> 
[snip]

If you decide on an alias it would be a good idea to add it to phobos 
for DMD 1, except without the const syntax of course.  That way people 
can start using it now and have less problems upgrading to DMD 2. 
Although, on the other hand, it may be slightly confusing on 1.0 coders 
I guess when it doesn't function as a const string.

-Joel



More information about the Digitalmars-d-announce mailing list