Top 5

Chris R. Miller lordsauronthegreat at gmail.com
Wed Oct 8 17:08:54 PDT 2008


Mike wrote:
> 4. Replace C-style switch with something modern and more D-like:
> 
> switch (x)
> {
>     case (0) foo();
>     case (1)
>     {
>         bar();
>         baz();
>     }
>     else throw new Exception("nope");
> }

But that would break the techniques of a duff's device.  The existing 
syntax of a switch statement is more accurate to how it behaves, 
anyways.  It's like a more complex series of goto statements.

http://en.wikipedia.org/wiki/Duff%27s_device
http://en.wikipedia.org/wiki/Switch_statement

Your proposal really makes it redundant with chains of if-else 
statements IMHO.



More information about the Digitalmars-d mailing list