removing default case requirement?

Dukc ajieskola at gmail.com
Sat Apr 1 14:28:51 UTC 2023


On Friday, 31 March 2023 at 15:20:41 UTC, Steven Schveighoffer 
wrote:
> 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?
>
> -Steve

On the one hand, it's not nearly always that I wish to break in 
the default case, often I want to `assert(0)` instead. This idea 
would encourage not checking for erroneous states, which is worse 
than usual since this check is free or almost free in runtime.

On the other hand, I sure like short code and it'd also be in 
line with what C and C++ do.

On balance, I maybe prefer current behaviour. D in general places 
greater emphasis on hardening the code against bugs than most 
languages do. It's not Ada or Rust, but still. If we were talking 
about a typical quick-and-dirty scripting language, the change 
could fit it better, but it's not as good for D IMO.


More information about the Digitalmars-d mailing list