C++ Logo

std-proposals

Advanced search

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

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Thu, 19 Dec 2024 11:02:30 +0000
I agree, even though you can make N3355 work, it’s just messy.
I don’t want to use labels to continue, I want to name my control flow statements and identify to what my continue applies.
I feel N3377 is better, its clear, easy to understand, no need to touch anything else.
It’s a personal opinion.
And I think trying to confuse what we want to achieve with this with a “label” in the same way as the “goto label” is using, is detrimental to the proposal.


From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of JeanHeyd Meneide via Std-Proposals
Sent: Wednesday, December 18, 2024 11:10 PM
To: std-proposals_at_[hidden]
Cc: JeanHeyd Meneide <phdofthehouse_at_[hidden]>
Subject: Re: [std-proposals] Bringing break/continue with label to C++

N3355's syntax is worse because it uses the labels. Unlike other languages where labels are somewhat normal and perhaps nicely scoped, labels in C and C++ defy scope (they exist inside of the function as a whole). That makes it hard to compose and reuse labels; N3377 discusses this and other reasons.

During the discussion in October, WG14 also had hangups around what was accepted; the consensus was not unanimous. N3377 will patch up those concerns -- including my own -- very nicely.

I look forward to seeing N3377 soon in WG14, and hopefully adding it to C2y.

Sincerely,
JeanHeyd

On Wed, Dec 18, 2024 at 4:10 PM Jens Maurer via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:


On 18/12/2024 11.49, Jan Schultke via Std-Proposals wrote:
> I want to have break/continue statements with labels in C++. Now is the time.
>
> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3355.htm has been
> accepted into C2y, with the syntax:
>
> label: for (/* ... */) {
> while (true) { break label; }
> }
>
> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3377.pdf proposes to
> update this syntax to
>
> for label (/* ... */) {
> while (true) { break label; }
> }
>
> While N3377 may be a bit more syntactically sound (not reusing labels
> that are otherwise only goto targets, I'm not a fan of that idea.

I think the strictly worst option would be if WG14 picked
the N3377 syntax, but WG21 picked the N3355 syntax.
So, WG21 needs to know WG14's opinion on N3377 before
committing to anything.

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

Received on 2024-12-19 11:02:34