removing default case requirement?

Ivan Kazmenko gassa at mail.ru
Sun Apr 2 17:33:10 UTC 2023


On Friday, 31 March 2023 at 15:20:41 UTC, Steven Schveighoffer 
wrote:
> But we have such a thing, in the `default:` case requirement.
> ...
> If we wanted to relax this requirement it's actually an easy 
> change -- no currently-compiling code will break.
>
> Why not? How much does this rule help you, vs. annoy you?

I rarely use switch at all.  Most of the time, it's too verbose 
to my taste, and has little benefit compared to a chain of 
if-else-if.  On top of that, I pause to ponder what is the 
Right(TM) indentation style.

When I do use switch -- or a chain of if-else-if for that matter 
-- it often ends with a default case with assert(false) or 
similar.  Or it should -- so, I do have a use for the default 
being required.

That said, given the verboseness of switch, I see a valid reason 
to question the current state.

Ivan Kazmenko.



More information about the Digitalmars-d mailing list