C++ Logo

std-proposals

Advanced search

Re: [std-proposals] MACROS

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Sat, 30 Apr 2022 11:59:08 +0200
Why not simply use `for (auto x : y)`?

```
for (auto i : infinity()) { } //could write to volatile memory to avoid UB
for (auto i : std::views::iota(1, 10)) { }
for (auto i : unitil([&]{ return true; })) { }
for (auto i : rep_until([&]{ return true; })) { }
```

sob., 30 kwi 2022 o 07:50 Abdullah Qasim via Std-Proposals
<std-proposals_at_[hidden]> napisał(a):
>
> OK, I take it back.
>
> It is better implemented as keywords
>
>
>
> From: William Linkmeyer via Std-Proposals
> Sent: 28 April 2022 22:05
> To: std-proposals_at_[hidden]
> Cc: William Linkmeyer
> Subject: Re: [std-proposals] MACROS
>
>
>
> +1 — this would be a highly unusual addition to the standard.
>
> > On Apr 28, 2022, at 12:58 PM, Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> wrote:
> >
> > You failed to present any motivation for these changes. Furthermore, I
> > don't know why we would want to add a bunch of macros (which cannot be
> > imported from a module) for such trivial things. Since we got
> > range-based for loops, the number of times I've had to loop over a
> > count is dramatically reduced. And with `ranges::iota` or similar
> > tools, that's now pretty much never. Having a way to spell
> > `while(!expr)` seems pointless; just read the expression.
> >
> > And `rep` is just a bad idea. `while(true)` is an incredibly dangerous
> > thing with a myriad of side-effects (if you don't do certain things in
> > the loop, the forward progress guarantees of the standard allow the
> > compiler to straight-up drop the loop body). It's sufficiently
> > dangerous that we should absolutely not have a short-form version of
> > it.
> > --
> > Std-Proposals mailing list
> > Std-Proposals_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2022-04-30 09:59:16