> I’d like to use switch instead of some new construct

Switch is a very thorny contraption, it's a remnant of an older time and it's just not good language design. Switch cases falling through are bug-prone and everyone runs into problems with "error: jump to case label crosses initialization of xyz" etc. The mere notion of able to write nonsense like the following is not a good thing:

switch(n) {
    while(n--) {
        case 10:
          foo(n);
        case 20:
          bar();
        default:;
    }
}

Switch will never go away, but we should move to something better.

Jeremy

On Tue, May 20, 2025 at 10:36 AM Filip via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
> `switch` should not be looked on as something that has a future.

Maybe just a preference but I’d like to use switch instead of some new construct. Seems like an easy thing to do.

Cheers, Filip

Wiadomość napisana przez Jason McKesson via Std-Proposals <std-proposals@lists.isocpp.org> w dniu 20 maj 2025, o godz. 15:52:

`switch` should not be looked on as something that has a future.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals