Higher level built-in strings
Steven Schveighoffer
schveiguy at yahoo.com
Tue Jul 20 10:44:32 PDT 2010
On Tue, 20 Jul 2010 11:02:57 -0400, Sean Kelly <sean at invisibleduck.org>
wrote:
> Steven Schveighoffer Wrote:
>>
>> How do we make this work?
>>
>> auto str = "hello world";
>> foreach(c; str)
>> assert(is(typeof(c) == dchar));
>
> foreach (dchar c; str)
> assert(...);
>
> This feature has been in D for years.
The omission of dchar is on purpose. Phobos has characterized string as a
bidirectional range of dchars. For every range where I do:
foreach(e; range)
e is of the type of the range. Except for char and wchar. This
schizophrenia of type induction is very bad for D, and it's a good
argument of why strings should not simply be arrays.
-Steve
More information about the Digitalmars-d
mailing list