Why foreach(c; someString) must yield dchar

Pelle pelle.mansson at gmail.com
Thu Aug 19 01:46:32 PDT 2010


On 08/19/2010 04:37 AM, dsimcha wrote:
> I've been hacking in Phobos and parallelfuture and I've come to the conclusion
> that having typeof(c) in the expression foreach(c; string.init) not be a dchar
> is simply ridiculous.  I don't care how much existing code gets broken, this
> needs to be fixed.  Otherwise, all generic code will have to deal with it as a
> special case.  Most of it will probably overlook this special case in
> practice, and the net result will be more broken code than if we just bite the
> bullet and fix this now.

Currently, strings break foreach in generic code. This is terrible!

I agree with this. I thought char[] was a UTF-8 sequence, not a byte 
sequence.


More information about the Digitalmars-d mailing list