C++ Logo

std-proposals

Advanced search

Re: [std-proposals] P2809R0 Infinite loops

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Tue, 4 Apr 2023 22:04:21 +0200
wt., 4 kwi 2023 o 19:44 Frederick Virchanza Gotham via Std-Proposals
<std-proposals_at_[hidden]> napisaƂ(a):
>
>
>
> On Tuesday, April 4, 2023, Marcin Jaczewski via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>
>> I wonder why not make infinite loops simply explicit?
>> Like:
>>
>> ```
>> while (std::infiniti) { }
>> ```
>
>
>
> Specifically, are you saying that the above loop will fail to compile if it contains one of the following?
> (1) break
> (2) throw (without catch)
> (3) return
> (4) longjmp
>

`throw` and `longjmp` could be allowed, as they are "outside" of this
loop. `break` and `return` could be a warning or hard error as it bit
contradicting
the stated intention.
And this is a bit side track, as the main goal was to inform the
compiler how it should handle this loop (aka do not elide it
completely).

> Are you saying that the compiler shall terminate compilation and issue a diagnostic if any of the above four are found inside a loop whose predicate is 'std::infinity'?
>
> By the way in English we spell it 'infinity'.

No, I used Motor Company name as identifier ;P

> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-04-04 20:04:33