C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Bringing break/continue with label to C++

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Tue, 7 Jan 2025 03:54:56 +0200
On Tue, 7 Jan 2025 at 03:35, Hyman Rosen via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Attaching labels to do/for/while/switch statements and having gotos target them is already legal in C and C++. If someone needs that construct, they can already use it whether the would-be masters of C++ style like it or not. So the argument against using those labels for break/continue seems to be that programmers would not normally write such gotos, but once they attach the labels, the temptation will be so overwhelming that they won't be able to help themselves. Which ... I can't even.

That's not the argument. The argument is that if you happen to have
gotos in your code, and I happen to have labeled loops in the same
code, I don't
have to consider my labeled loops as possible targets of your
spaghetti jumps, because they can't be. I don't need to include them
in my search for
the possible targets of your spaghetti jumps.

Received on 2025-01-07 01:55:10