On 1/15/11 10:47 PM, Michel Fortin wrote:
On 2011-01-15 22:25:47 -0500, Jonathan M Davis <jmdavisp...@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.

I think it's poor abstraction to represent a Grapheme as a string. It should be its own type.

Andrei

Reply via email to