C++ Logo

std-proposals

Advanced search

Re: [std-proposals] !continue

From: David Brown <david_at_[hidden]>
Date: Mon, 6 Nov 2023 17:36:04 +0100
On 06/11/2023 17:25, Chris Gary via Std-Proposals wrote:
> I'm not sure if someone's already mentioned this, but is there anything
> wrong with making this into a "while"?

Yes, it has been mentioned. Certainly IMHO the code was crying out for
a "while" rather than a badly organised "for", and I can't understand
why anyone would want a new unusual syntax for this special case.

>
> I'm aware of the limitations of embedded environments like an Arduino,
> and so understandably there should really be more error handling to do
> with the buffer filling up and other things.

Maybe, maybe not. In small embedded systems, you usually have a much
clearer idea of what errors can occur - and what errors cannot. And you
frequently have very limited options for dealing with errors - just
silently dropping any overflow characters can be a perfectly good strategy.

>
> I've often found myself in need of some way to break out of nested
> loops, or break from a loop within a switch statement, but then later
> found it could be refactored into something more readable.

Options include refactoring into functions with early returns, or extra
flag variables - these are free (assuming a half-decent compiler),
giving you the run-time effect of gotos or multi-level break/continue
statements, and with good names their function is clear.

Received on 2023-11-06 16:36:10