What's left for 1.0?

Marcin Kuszczak aarti at interia.pl
Thu Nov 16 14:09:25 PST 2006


Bill Baxter wrote:

> So, what's left on everyone's lists for D1.0 must-have features?

I think that one thing which is missed in phobos right now is string class
which encapsulates utf-8/utf-16/utf-32 handling and issues connected with
utf-8 strings e.g.:

        char[] foo = "hög";
        assert(foo.length == 3); // Sorry UTF-8, this is == 4
        assert(foo[1] == 'ö');   // Not a chance!

It's really annoying to write application in language different than English
(or multi-language application) using just currently available language
support (please note that I am not saying that in C++ it's better :-) - I
am just saying that it could be greatly improved).

Problems which I see with current language support are:
1. You need 3 types of functions which are doing same, but getting different
char arrays - char[]/wchar[]/dchar[] as parameters, to write good API you
have to write. Best (maybe I should write worst ;-) ) example is Phobos API
2. It's quite easy to make wrong assumptions about utf-8 encoded arrays. See
example above. It could cause slicing string in wrong place, making it
improperly formatted utf-8 string.
3. What is char[] is probably not so clear for newbies. Especially for
utf-8: is char really one character/code point?
4. String class should be more than just array of characters. It should
probably have some more methods like e.g. removing characters from middle
of string and much more.

Some time ago Chris Miller posted on news list dstring implementation which
looks quite good for me(link to site:
http://www.dprogramming.com/dstring.php).

But if Walter is not happy enough with this implementation now maybe there
should be at least added alias in object.d:
alias char[] string;

I personally vote for dstring.

-- 
Regards
Marcin Kuszczak
(Aarti_pl)



More information about the Digitalmars-d mailing list