C++ Logo


Advanced search

Re: [std-proposals] Proposal regarding labeld breaking and continuation

From: Bo Persson <bo_at_[hidden]>
Date: Fri, 17 Feb 2023 15:25:40 +0100
On 2023-02-17 at 13:30, Hypatia (of) Sva via Std-Proposals wrote:
> Hello Members or WG21,
> I have written up this proposal for labeled breaking and continuation,
> because I was kind of annoyed that this feature, which Fortran got in
> 1990, is still not present in neither C nor C++. I would be interested
> if anyone would have comments on both the content and form ot this
> proposal. As by the advice on isocpp.org I took a draft from
> https://github.com/mpark/wg21/, namely the one about pattern matching,
> and changed it to what I wanted to write, I would be interested if this
> form seems appropriate or if I made any mistakes here. I would also be
> interested to know how the document numbers come about, it seemed to be
> based on the date so that's what I went with, but that may be wrong so
> I'm waiting for your feedback on this.
> Hypatia of Sva.
> Formatted, see:
> https://github.com/hypatia-of-sva/documents/blob/main/P230217R0.pdf
> Markdown Text (see also
> https://raw.githubusercontent.com/hypatia-of-sva/documents/main/P230217R0.md ):

The critique might be to question how useful this really is. Personally
I have never had much problem with exiting nested loops. Occationally I
have used a condition flag, but most often the solution is to put the
loop in a function/lambda and use a return to terminate the outer loop.

I have never, ever, felt a need to restart an outer loop from an inner
loop. Does that really happen?

Hardly ever use continue either, as an

if (condition)

most often can be replaced by

if (!condition)
    // rest of the loop

so I feel no strong need to "improve" continue at all.

The goto error and cleanup seems like something the C committee perhaps
could be interested in. In C++ we already have destructors for the
cleanup, so not much need for another way of doing a similar thing.

And also, I find the label in the left margin looking really, really
ugly. But perhaps that is a good thing, as it urges me to avoid using it!

Received on 2023-02-17 14:25:49