News for hackers. Stuff that matters.
Re:The Performance Impact of C++'s `final` Keyword by wvenable on Monday April 22, 2024 @03:33PM (#40118072)
C# has both switch expressions like this and also break statements are not optional in traditional switch statements so it actually solves both problems. You can't get too clever with switch statements in C#.

However most languages have pretty permissive switch statements just like C.

Re:The Performance Impact of C++'s `final` Keyword by tombert on Monday April 22, 2024 @03:47PM (#40118468)
Yeah, fair, it's been awhile since I've done any C#, so my memory is a bit hazy with the details. I've been burned C with switch statements so I have a pretty strong distaste for them.
Re:The Performance Impact of C++'s `final` Keyword by smaudet on Tuesday April 23, 2024 @09:22AM (#40131685)
I think using C as your language with which to judge language constructs is hardly fair - one of its main strengths has been as a fairly stable, unchanging code-to-compiler contract, i.e. little to none syntax change or improvements.

So no offense, but I would revisit the wider world of language constructs before claiming that switch statements are "all bad". There are plenty of bad languages or languages with poor implementations of syntax, that do not make the fundamental language construct bad.