What's left for 1.0? - string class

Aarti_pl aarti at interia.pl
Fri Nov 17 08:12:11 PST 2006


Anders F Björklund napisał(a):
> Aarti_pl wrote:
> 
>>> char and wchar are nothing special, but char[] and wchar[] are magic.
>>> If those used ubyte[] and ushort[], code point looping wouldn't work.
>>
>> so it works now?
> 
> Sure:
> 
> import std.stdio;
> 
> void main() {
>     char[] text="Łóżko";
>     foreach(wchar c; text) {
>         writefln(c);
>     }
> }
> 
> --anders

True... You are right...

But anyway I don't think that we need magic in compiler... I would say 
that we need straightforward solutions which could be easily used.

Making size of char equal to 4 bytes, and having string class, which can 
optimize different encodings would allow to get rid of all magic... :-)

Below is just a dream:
# void main() {
#     string text="Łóżko";     // string class which uses 
ubyte/ushort/char for different internal representation; string could 
optimize texts for speed or memory consumption
#     foreach(char c; text) {  // char is always unicode 4 bytes
#         writefln(c);
#     }
# }

Regards
Marcin Kuszczak



More information about the Digitalmars-d mailing list