C++ Logo

std-proposals

Advanced search

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

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Fri, 20 Dec 2024 12:28:42 +0100
E.g. Perl, Go, D   https://perldoc.perl.org/functions/next https://perldoc.perl.org/functions/goto   https://go.dev/ref/spec#Continue_statements https://go.dev/ref/spec#Goto_statements   https://dlang.org/spec/statement.html#continue-statement https://dlang.org/spec/statement.html#goto-statement     -----Ursprüngliche Nachricht----- Von:Tiago Freire via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Fr 20.12.2024 12:00 Betreff:Re: [std-proposals] Bringing break/continue with label to C++ An:std-proposals_at_[hidden]; CC:Tiago Freire <tmiguelf_at_[hidden]>; > On the contrary, there is tons of precedent for "break label" in other mainstream > languages; see https://eisenwave.github.io/cpp-proposals/break-continue-label.html#argumentum-ad-populum > Just counting source files on GitHub, we have hundreds of thousands of such uses.   Actually, No.  Cy2 is not official Java, JavaScript, TypeScript, Kotlin, Rust, Ruby, don't have a goto statements so they are not goto labels.   If C++ had used label@ for() instead of  label: for()   It would have a point, as it is, the paper is extremely misleading (if not right out deceptive) in this point.         -------------------------------- From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Jan Schultke via Std-Proposals <std-proposals_at_[hidden]> Sent: Friday, December 20, 2024 10:26 To: std-proposals_at_[hidden] <std-proposals_at_[hidden]> Cc: Jan Schultke <janschultke_at_[hidden]> Subject: Re: [std-proposals] Bringing break/continue with label to C++   Hi Filip, thanks for your feedback. > I made a proposal about this problem earlier and I still believe that using continue/break with labels is just a nice looking goto. I saw that, and I very briefly discuss it under https://eisenwave.github.io/cpp-proposals/break-continue-label.html#why-not-break-n In my opinion, even if we designed from a blank slate, "break N" or "break break" or "break for" are much harder to reason about when you start nesting loops more deeply. It's also possible to break or change the meaning of code when replacing a while loop with a for loop, a loop with an if statement, etc. The only other language that takes this non-label approach is PHP, so there's very little precedent in other languages. On the contrary, there is tons of precedent for "break label" in other mainstream languages; see https://eisenwave.github.io/cpp-proposals/break-continue-label.html#argumentum-ad-populum Just counting source files on GitHub, we have hundreds of thousands of such uses. "break label' is what people expect. It works. However, also keep in mind that C2y has already decided on having "break label", and even N3377 does not fundamentally change that design. Your idea is not C-compatible (neither with N3355 nor with N3377), and that's reason alone not to pursue it further. > Maybe it should be done with attribute as a label? Attributes are designed as information that the compiler is free to ignore. "break label" cannot refer to a label that's simply ignored by the compiler in some way, so attributes are not an option. -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-12-20 11:30:56