Rainer Deyke Wrote:

> On 11/22/2010 11:55, Andrei Alexandrescu wrote:
> > http://d.puremagic.com/issues/show_bug.cgi?id=5257
> 
> I think this bug is a symptom of a larger issue.  The range abstraction
> is too fragile.  If even you can't use the range abstraction correctly
> (in the library that defines this abstraction no less), how can you
> expect anyone else to do so?

Note that this issue with foreach has been discussed before. The suggested 
solution was to have infer dchar instead of char (shot down since iterating 
char is useful and it is simple to add the type dchar). Maybe a range interface 
(as found in std.string) should take precedence over arrays in foreach? Or 
maybe foreach should only work with ranges and opApply (that would mean 
std.array would need imported to use foreach with arrays)?

That wouldn't address your exact issue. I tend to agree with Andrei as you 
should be coding to the Range interface which will prevent any miss use of 
char/wchar. On the other hand, why can't I have a range of char (I mean get one 
from an array, not that I would ever want to)?

Anyway, I agree char[] is a special case, but I also agree it isn't an issue.

Reply via email to