VLERange: a range in between BidirectionalRange and RandomAccessRange

Michel Fortin michel.fortin at michelf.com
Sat Jan 15 20:47:11 PST 2011


On 2011-01-15 22:25:47 -0500, Jonathan M Davis <jmdavisProg at gmx.com> said:

> The issue of foreach remains, but without being willing to change what 
> foreach defaults to, you can't really fix it - though I'd suggest that 
> we at least make it a warning to iterate over strings without 
> specifying the type. And if foreach were made to understand Grapheme 
> like it understands dchar, then you could do
> 
> foreach(Grapheme g; str) { ... }
> 
> and have the compiler warn about
> 
> foreach(g; str) { ... }
> 
> and tell you to use Grapheme if you want to be comparing actual characters.

Walter's argument against changing this for foreach was that it'd 
*silently* break compatibility with existing D1 code. Changing the 
default to a grapheme makes this argument obsolete: since a grapheme is 
essentially a string, you can't compare it with char or wchar or dchar 
directly, so it'll break at compile time with an error and you'll have 
to decide what to do.

So Walter would have to find another argument to defend the status quo.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list