C++ Logo

std-proposals

Advanced search

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

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Fri, 20 Dec 2024 11:33:34 +0000
> Tiago, you're the only person here who keeps insisting that "goto labels" are fundamentally different from "loop labels".

No. I'm proposing that they fundamentally should be.

label: for(...)
{
 if(cond1) break label;
 if(cond2) continue label;
 if(cond3) goto label;
}

Are 3 different jumps

I want to be able to break and continue on a certain loop, not create a point where goto can be used.
Trying to force goto semantics is just tempting the faiths and spreading confusion.

It's a unique feature that is being tried to push into C++. No other language does this!

If you want to name the loop, name the loop, don't create a label that you can goto.

> I am proposing the same for C++. That piece of code has the EXACT SAME syntax and the EXACT SAME semantics in e.g. Java. However, because C++ also has "goto label", it is DECEPTIVE to say it's the same as Java?!

Java has no goto, so it semantically not a label in the same way a goto label is in C++


-----Original Message-----
From: Jan Schultke <janschultke_at_googlemail.com>
Sent: Friday, December 20, 2024 12:22 PM
To: Tiago Freire <tmiguelf_at_hotmail.com>
Cc: std-proposals_at_[hidden]
Subject: Re: [std-proposals] Bringing break/continue with label to C++

Tiago, you're the only person here who keeps insisting that "goto labels" are fundamentally different from "loop labels". Fundamentally, they're both labels which add a name to a following statement. Whether that label ends up being used as the jump target for goto, or to identify the loop which is targeted by "break" doesn't change this.
It's still a label for a statement.

If I write "int x = 0;" and never reassign "x", that doesn't change the fact that it's a mutable variable. It's not an immutable constant.
How things are used doesn't change what they are.

> It would have a point, as it is, the paper is extremely misleading (if not right out deceptive) in this point.

This is an absurd claim. Multiple other languages have:
> label: while (true) break label;

I am proposing the same for C++. That piece of code has the EXACT SAME syntax and the EXACT SAME semantics in e.g. Java. However, because C++ also has "goto label", it is DECEPTIVE to say it's the same as Java?!

Please stop arguing in such bad faith. You probably don't believe this nonsense yourself. This isn't the first time on [std-proposals] you've used the argument that ideas are bad because they don't fit your bigoted mental model; not on technical merits.

Received on 2024-12-20 11:33:36