On Sunday 18 July 2010 06:16:09 strtr wrote: > I agree with the warning. A good warning would get people to read up on > UTF. And if you really want to have char you'll need to cast: > foreach(cast(char)c; chars)
Actually, the cast would be totally unnecessary. Putting foreach(char c; chars) would be enough. Forcing a cast would change how foreach normally works. I'm not even sure that you can legally put a cast there like that. What we'd want to disallow would be foreach(c; chars) As long as the programmer puts the element type, we can assume that they know what they're doing. But warning in cases where they don't put it would catch a large number of errors in iterating over strings and wstrings. In any case, I filed a bug report for it: http://d.puremagic.com/issues/show_bug.cgi?id=4483