C++ Logo

std-proposals

Advanced search

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

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Mon, 6 Jan 2025 11:08:37 +0000
+1 the sentiment.
Trying to eliminate goto from the language is counterproductive.
You can always eliminate it by “not-using it in your code”.
We should care more on how to go from here.

From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of Richard Hodges via Std-Proposals
Sent: Monday, January 6, 2025 10:57 AM
To: std-proposals_at_[hidden]
Cc: Richard Hodges <hodges.r_at_[hidden]>
Subject: Re: [std-proposals] Bringing break/continue with label to C++



On Sun, 5 Jan 2025 at 15:50, Avi Kivity via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:
On Fri, 2024-12-20 at 16:42 +0200, Ville Voutilainen via Std-Proposals
wrote:
> On Fri, 20 Dec 2024 at 16:40, Jan Schultke
> <janschultke_at_[hidden]<mailto:janschultke_at_[hidden]>> wrote:
> >
> > > > See, the 'dislike' for goto isn't a 'dislike' at all.
> >
> > > Yes, it is.
> >
> > Or to be fair, no, I'm wrong. That's not what I was trying to say.
> >
> > It totally see the issue with goto. But dislike for using "label:"
> > syntax IS a pure dislike. It has nothing to do with cyclomatic
> > complexity and is just a means to circumvent using naming
> > conventions
> > and writing linter scripts. It's not technically necessary.
>
> Yes, linter scripts can also be used for banning conversions between
> unrelated pointers, so we don't actually need
> type safety in a programming language.
>
> Or linter scripts can be used to make sure you don't have
> memory-safety problems in your programs, so we don't
> need memory-safe programming languages.
>
> Linter scripts are a solution yet to show its effectiveness. And
> that's been the case for various suggestions of their
> use for more than 40 years.


Wouldn't something like -Werror=goto suffice here?

switch/case is at its core syntactic sugar for a sequence of goto.
continue and break are syntactic sugar for goto.

Hand wringing over the presence of goto in a program is an utterly pointless exercise performed by people who like to pretend that computers work differently to the way they actually do.

There is absolutely no reason why goto cannot be compiled at compile time. If while(1) { if (condition() break; } can work at compile time, so can goto.

Can we stop doing this? It's been 40 years. Honestly...



--
Std-Proposals mailing list
Std-Proposals_at_[hidden]<mailto:Std-Proposals_at_[hidden]>
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-01-06 11:08:43