C++ Logo


Advanced search

Re: [std-proposals] [Proposal] switch for Pattern Matching

From: Barry Revzin <barry.revzin_at_[hidden]>
Date: Tue, 25 Apr 2023 21:38:30 -0500
On Mon, Apr 24, 2023 at 2:09 PM Михаил Найденов via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Hello,
> Here is a short proposal to re-use `switch` for Pattern Matching.

Just so I'm clear. The argument is that introducing a new facility, with
new semantics, under a new token (whether inspect or match) would be bad
for teachability.

So instead, you're proposing that we reuse an existing token (switch) to
introduce two very different behaviors (statement vs expression, best match
vs first match, fallthrough vs exactly one arm, integers vs more complex
patterns, etc.), but since those different behaviors still need to be
differentiated by the parser, you're proposing we do so by simply switching
from parentheses to square brackets around the operand? And you're
proposing that having 'switch' mean two very different things is better for

Doesn't seem like a great idea to me.


Received on 2023-04-26 02:38:42