bearophile wrote:
Don:
(1) "case A, B, C:" implies a relationship between A, B, and C, which
might not exist. They may have nothing in common.
It's just a list of things, it's a syntax people adapts too. Here too there's
no relationship between x and foo:
int x, foo;
(2) it's an extremely common coding style in C, C++.
If automatic fall-through becomes a syntax error, then allowing it for empty
case statements is a special case of a special case. This kind of complexity
kills languages. As they say in Python Zen:
Special cases aren't special enough to break the rules.
And this is D.
(3) it's more difficult to read.
You can put items in one column anyway, so instead of:
case someverylongcase:
case anotherverylongcase:
case thelastverylongcase:
You can write:
case someverylongcase,
anotherverylongcase,
thelastverylongcase:
This is not so unreadable.
----------------------
Justin Johansson:
Actually I quite like the brevity you propose but would
it be a challenge for the comma operator?
That's already standard D syntax :-)
http://codepad.org/ByvTAs27
Bye,
bearophile
> That's already standard D syntax :-)
Okay, thanks for reminding me.**
> What's bad about forcing people to write case A, B, C
So your use of the word "forcing" was quite intentional?
Cheers. Must go now to attend to some fall-through cases in my
switch statements.** Justin.