removing default case requirement?

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Fri Mar 31 18:38:38 UTC 2023


On 01/04/2023 7:30 AM, Steven Schveighoffer wrote:
> On 3/31/23 12:28 PM, Richard (Rikki) Andrew Cattermole wrote:
>> I prefer having the current behavior, it gives good guarantees that 
>> all possible situations are handled, including no-operation.
>>
>> Inaction is just as much an action, as any other action. Having 
>> compiler enforced is very reassuring that everything is handled and 
>> done so intentionally.
> 
> Do you feel the same about if statements without `else`? Why is it 
> different?
> 
> -Steve

No.

Usually if statements is when you want to handle non-linear control 
flow. They require higher levels of scrutiny to ensure they are correct 
for the overall function flow to be correct.

Think about it in terms of flow chart. A switch statement is just a 
process step, whereas an if statement would be a conditional.


More information about the Digitalmars-d mailing list