Walter Bright wrote: ... > The way to do strings in D is to have them be immutable. If you are > building a string by manipulating its parts, start with mutable, when > finished then convert it to immutable and 'publish' it to the rest of > the program. Mutable char[] arrays should only exist as temporaries. > This is exactly the opposite of the way one does it in C, but if you do > it this way, you'll find you never need to defensively dup the string > "just in case" and things just seem to naturally work out. > > I tend to agree that if you try to do strings the C way in D2, you'll > probably find it to be frustrating experience.
That is a really helpful insight. It also means string programming is a bit different in D2 than in D1. At some point in time, it might be helpful to add a little introduction 'howto program with strings' to the D documentation. After all, it is a major feature of D and departure from C and C++.