request switch statement with common block

Kagamin spam at here.lot
Sun Aug 4 03:14:45 PDT 2013


On Saturday, 3 August 2013 at 18:56:47 UTC, JS wrote:
> Um, it can actually save a lot of type and errors.
>
> having two places to change is very error prone.
>
> if (cond) { }
> switch(cond)

What is error-prone is evaluation of a complex condition twice 
assuming it will result in the same value. That's also a common 
error with C macros. You should save the value in a variable:

auto cond = complexCond;
if (cond) { }
switch(cond)...


More information about the Digitalmars-d mailing list