Is there ANY chance we can fix the bitwise operator precedence

Michel Fortin michel.fortin at michelf.com
Sun Jun 20 18:22:25 PDT 2010


On 2010-06-20 19:42:49 -0400, bearophile <bearophileHUGS at lycos.com> said:

> I think he means every case. Sometimes a small change, even if seems a 
> little less handy, is useful. Can't you write code like this, that also 
> looks better to me?
> 
> import std.stdio: writeln;
> void doSomething() { writeln("doSomething"); }
> void whatever() { writeln("whatever"); }
> void main() {
>     int x = 4;
>     switch (x) {
>         case 1, 2, 3, 4:
>             doSomething();
>             break;
>         default:
>             whatever();
>             break;
>     }
> }

But what about the "case 1: ... case 10:" syntax?

	switch (x) {
		case 1: .. case 10:
		case 22: .. case 32:
		case 52, 64:
			doSomething();
			break;
		default:
			whatever();
			break;
	}


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



More information about the Digitalmars-d mailing list