semi-final switch?

Dennis dkorpel at gmail.com
Thu Jun 17 21:54:57 UTC 2021


On Thursday, 17 June 2021 at 21:41:28 UTC, Steven Schveighoffer 
wrote:
> Any ideas on better ways to handle this?

I've had such a situation before too where I want to switch over 
enums I read from an ELF file which can't be assumed to be 
correct, but I also don't want to forget one. For a tight 
numerical enum you simply check `if (i <= EnumType.max)`, but 
when there's gaps (or strings like in your case) that doesn't 
work. I got the idea for a DIP to allow a `default` statement in 
`final switch` to allow a custom error handler instead of the 
default `__switch_error`, but never pursued it further. I'm still 
in favor of it though.



More information about the Digitalmars-d-learn mailing list