Date: Mon, 16 Nov 2026 20:03:08 -0500
Hello.
Your code looks equivalent to the following: https://godbolt.org/z/TEEWzrM3E
In this case, because x is allowed to be 3-or-more, it will sort-of
infinite loop on the second iteration. This will be a footgun with this
sort of code style. Very hard to debug (similar to using goto).
That said, if you do want a repeat-like pattern, then you can use the
lambda-in-a-while-loop trick works. Isolate the body to a lambda, and call
it as the condition part of a while loop. When you want to "repeat" you
just return true. Otherwise return false.
On Mon, Nov 16, 2026 at 11:41 AM scbd Gm via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Hello everyone,
>
> I'm interested in proposing a new C++ control-flow statement called repeat
> .
>
> The motivation is to provide a dedicated way to restart the current loop
> iteration immediately, without executing the remaining statements or the
> loop's increment expression.
>
> For example:
>
> int x = 0;
>
> for (int i = 0; i < 5; i++)
> {
> x++;
>
> cout << "Hello\n";
>
> if (x != 2)
> repeat;
> }
>
> My proposed semantics are:
>
> 1.
>
> Restart the innermost enclosing loop body.
> 2.
>
> Skip the remaining statements of the current iteration.
> 3.
>
> Do not execute the loop's increment expression.
> 4.
>
> Destroy and reinitialize local objects belonging to the loop body's
> scope.
> 5.
>
> Preserve variables declared outside the loop body.
> 6.
>
> Support for, while, and do-while loops.
>
> I believe this could provide a cleaner and more expressive alternative to
> certain uses of goto and nested loops.
>
> I would appreciate feedback on:
>
> -
>
> Whether this feature offers sufficient practical value.
> -
>
> Whether similar functionality has been proposed before.
> -
>
> Potential problems with object lifetimes, destructors, and exception
> handling.
> -
>
> Whether this idea could be worth developing into a formal C++ proposal.
>
> This is an early-stage idea, and I would appreciate constructive criticism.
>
> Thank you!
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Your code looks equivalent to the following: https://godbolt.org/z/TEEWzrM3E
In this case, because x is allowed to be 3-or-more, it will sort-of
infinite loop on the second iteration. This will be a footgun with this
sort of code style. Very hard to debug (similar to using goto).
That said, if you do want a repeat-like pattern, then you can use the
lambda-in-a-while-loop trick works. Isolate the body to a lambda, and call
it as the condition part of a while loop. When you want to "repeat" you
just return true. Otherwise return false.
On Mon, Nov 16, 2026 at 11:41 AM scbd Gm via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Hello everyone,
>
> I'm interested in proposing a new C++ control-flow statement called repeat
> .
>
> The motivation is to provide a dedicated way to restart the current loop
> iteration immediately, without executing the remaining statements or the
> loop's increment expression.
>
> For example:
>
> int x = 0;
>
> for (int i = 0; i < 5; i++)
> {
> x++;
>
> cout << "Hello\n";
>
> if (x != 2)
> repeat;
> }
>
> My proposed semantics are:
>
> 1.
>
> Restart the innermost enclosing loop body.
> 2.
>
> Skip the remaining statements of the current iteration.
> 3.
>
> Do not execute the loop's increment expression.
> 4.
>
> Destroy and reinitialize local objects belonging to the loop body's
> scope.
> 5.
>
> Preserve variables declared outside the loop body.
> 6.
>
> Support for, while, and do-while loops.
>
> I believe this could provide a cleaner and more expressive alternative to
> certain uses of goto and nested loops.
>
> I would appreciate feedback on:
>
> -
>
> Whether this feature offers sufficient practical value.
> -
>
> Whether similar functionality has been proposed before.
> -
>
> Potential problems with object lifetimes, destructors, and exception
> handling.
> -
>
> Whether this idea could be worth developing into a formal C++ proposal.
>
> This is an early-stage idea, and I would appreciate constructive criticism.
>
> Thank you!
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2026-11-17 01:03:27
