C++ Logo

std-proposals

Advanced search

Re: [std-proposals] A draft for modern switch

From: Zhihao Yuan <zy_at_[hidden]>
Date: Sat, 24 May 2025 06:42:08 +0000
On Friday, May 23rd, 2025 at 8:18 PM, Thiago Macieira via Std-Proposals <std-proposals_at_[hidden]> wrote:

>

> > Pattern matching doesn't check either of
> > these. At a semantic level, patterns are tried
> > sequentially in from top to bottom, and users
> > must keep this in mind to write correct code.
>

>

> Which is often required, especially if we want to support something like
> regular expression matching or other matching methods that aren't completely
> disjoint.
>


That's not the point. Sure, from pattern
matching's point of view, many needs can
be "required." But `switch` is disjoint
by construction. Therefore, when comes to
performance, no matter how users write
it, it won't be inefficient. And when
comes to reading and modifying the code,
users can read each individual flow by
"jumping" into it - other "cases" do
not matter in that process.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

Received on 2025-05-24 06:42:18