C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] More flexible break statements.
From: JeanHeyd Meneide (phdofthehouse_at_[hidden])
Date: 2019-08-18 15:46:11


I will mildly note that capture-the-world-and-do-work is not viable in
templates where arguments or locals are templated, because this can very
easily result in a combinatoric explosion lambda types that the compiler
cannot elide properly (
https://thephd.github.io/sol3-compile-times-binary-sizes).

That said, that only applies in a "small" amount of cases, so I'm sure
working around it is deemed as more than acceptable, or just eating the
Goto.

FWIW, I was tempted to write the paper you wanted to write. Discussion
amongst a few members of the Committee made it painfully clear that the
paper would go Nowhere, even with motivating examples, because 7+ proposals
in the before-times already came around and effectively soured the taste of
such in everyone's mouth on top of the already violent disposition against
additional flow control statements:
https://github.com/ThePhD/future_cxx/issues/10

You're better off just using "goto" for now, however heinous many may
consider it. Maybe wait until C++32, when the ideas died down for a while
and we have more complex iteration techniques after building up large
amounts of ranges algorithms that might require more complex algorithm
internals where breaking out of 2+ loops or similar would be justified.

On Sun, Aug 18, 2019 at 2:43 PM Walt Karas via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> The lambda (with default capture by reference) looks like a good
> (existing) option to me.
>
> On Friday, August 16, 2019, 6:51:44 PM CDT, Arthur O'Dwyer <
> arthur.j.odwyer_at_[hidden]> wrote:
>
>
> On Fri, Aug 16, 2019 at 7:43 PM Walt Karas via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> 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.
>
>
> Once you're making up new meanings for control-flow keywords, what would
> be wrong with
>
> {
> /* yada */
> if (something) goto bottom;
> /* yada */
> }
> bottom:;
>
> or
>
> []() {
> /* yada */
> if (something) return;
> /* yada */
> }();
>
> ? C++ already has plenty of ways to spell "goto this place" and/or "break
> out of this level of nesting"; I don't think we need more.
>
> "goto case" and "goto default", on the other hand, should probably Just
> Work. Try to get buy-in from a compiler vendor. I wouldn't want to waste
> paper verbiage on them before showing that they can be useful in practice.
>
> my $.02,
> –Arthur
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>



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

Standard Proposals Archives on Google Groups