C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] More flexible break statements.
From: Walt Karas (wkaras_at_[hidden])
Date: 2019-08-16 18:43:48


 Another option would be to redefine 'break' as a void-returning expression, so that:
do { /* yada */ } while (0);
could become:
for ( ; ; break) { /* yada */ }
It's more readable if you know a loop isn't really a loop from the beginning.

    On Friday, August 16, 2019, 3:06:05 PM CDT, Ville Voutilainen <ville.voutilainen_at_[hidden]> wrote:
 
 On Fri, 16 Aug 2019 at 22:59, Walt Karas via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> 1.  'break short;' statement would break out of the immediately enclosing compound statement.  This would eliminate the need for the 'do { /* yada */ } while (0);' idiom.  It would be an error if the immediately enclosing compound statement were a function body.  (If the compound statement was a direct component of an iteration statement, 'break short;' would be the same as 'continue;'.)
>
> 2. 'break LABEL;' statement would break out of a directly or indirectly enclosing statement immediately preceded by the label 'LABEL:'.  It would be an error if no such statement existed.

Yeah, well, these ideas pop up every now and then. A paper containing
them, http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3879.pdf,
was discussed and rejected in Rapperswil 2014.



STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups