Case Range Statement ..
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jul 7 10:14:12 PDT 2009
Bill Baxter wrote:
> I really wish we would just go with two-dots for exclusive, three-dots
> for inclusive, and make that work consistently everywhere.
>
> The "too similar to see the difference" argument just doesn't hold
> weight with me. Unless you're programming in a proportional-width
> font the difference is pretty obvious.
That is troublesome because it introduces very weird semantics driven by
counting dots and inserting whitespace. Consider:
int wyda;
void main()
{
int wyda;
foreach (i; 0...wyda)
{
....
}
}
Now there are several problems with this. All of the following compile:
0.....wyda
0....wyda
0... .wyda
0. .. .wyda
0.... wyda
0. ...wyda
0. ....wyda
0.. .wyda
and many others too. Using "..." as a separator in addition to a
trailing symbol is bound to be a complete disaster.
> Or define some other char
> sequence to mean inclusive range. Like a ..|b or a..:b or a..^b,
> etc.
That is more sensible. But as far as switch is concerned, I'm thoroughly
content with what we have now, modulo the 256 limit.
Andrei
More information about the Digitalmars-d
mailing list