C++ Logo

std-discussion

Advanced search

Re: Proposal for switch statement extension

From: Jefferson Carpenter <jeffersoncarpenter2_at_[hidden]>
Date: Sat, 12 Sep 2026 01:47:56 -0500
On Sat, Sep 12, 2026 at 2:03 AM Michael Park <mcypark_at_[hidden]> wrote:
>
> The problem with switch is that the syntax for switch is not structured at all.
> The syntax for switch is essentially:
>
> switch (value) statement
>
> The statement there makes it such that any arbitrary sequence of statements can
> be written with cases written somewhere sometimes.
>
> It also has too much baggage around fall-through and requiring break, etc.

I agree with this point. I'd prefer the value in a new feature to
"look" more like a lambda body anyway, complete with a return
statement (or instead of a full lambda body, just a single expression
that gives the value). I may have more detailed ideas later.

>
> The committee has been pretty firm on "leave switch alone".

Interesting! I'm not surprised, but I wouldn't mind making little
improvements to this statement over adding a new language feature.

Received on 2026-09-12 07:20:55