Inside the switch statement

BCS none at anon.com
Tue Jun 9 23:54:28 PDT 2009


Hello Derek,

> On Tue, 9 Jun 2009 16:28:58 +0000 (UTC), BCS wrote:
> 
>> I'm sorry, you don't have my sympathy on this one. There are to many
>> place I've used fall throught to chuck it out.
>>
[...] 
> However, additionally in the default format you can use
> 'fallthru' to let flow drop to the next case....
> 
> switch EXPR do
> case VAL1 then
> STATEMENTS...
> case VAL2 then
> STATEMENTS...
> fallthru  -->>> This makes flow fall through.
> case VAL3 then
> STATEMENTS...
> end switch
> So, if one considers improving D's switch, it is possible to have both
> models if one is not frightened of new keywords.
> 
> For example ...
> 
> select (EXPR) {
> case VAL1:
> STATEMENTS...
> case VAL2:
> STATEMENTS...
> case VAL3:
> STATEMENTS...
> }
> would only execute ONE of the selected cases.
> 

C# sort of takes this approach (by using goto case EXP;) but doesn't have 
any generic "goto next" ability and I would find that very painful in some 
template code.




More information about the Digitalmars-d-learn mailing list