Date: Fri, 14 Mar 2025 13:04:18 -0500
Hi
> 1. using enum in for loop:
> for (auto e : someEnum) {...}
This is solved with reflection and libraries like magic enum.
> 2. Forcing unroll with a keyword and not `#pragma`
> inline for ( … )
The syntax `inline` is not really clear here, either. Maybe an attribute if
anything but I don't think this is very useful or should be standardized.
> 3. Run loop N times
> for ( 5 )
Why not just std::views::iota? I don't think it would be useful to make a
special-case syntax for such a thing. Even python decided against `for i in
5`.
Cheers,
Jeremy
On Fri, Mar 14, 2025 at 11:43 AM Filip via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> I want to ask for your comments about couple of different for loops ideas
> that I had recently:
>
> 1. using enum in for loop:
> ```
> for (auto e : someEnum) {...}
> ```
>
> Since compiler knows the elements of `ENUM` it should be able to easily
> unroll the loop or iterate over the elements of enum.
>
> 2. Forcing unroll with a keyword and not `#pragma`
> ```
> inline for ( … )
> ```
> It could force the unroll like similar construct does in zig.
> This syntax already exists and we could probably easily implement it.
>
> 3. Run loop N times
> ```
> for ( 5 )
> ```
> Running for loop N number of times is a common issue e.g. N tries to
> connect to the server.
> This way would not pollute the namespace with additional `int i` that we
> frankly don’t use.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> 1. using enum in for loop:
> for (auto e : someEnum) {...}
This is solved with reflection and libraries like magic enum.
> 2. Forcing unroll with a keyword and not `#pragma`
> inline for ( … )
The syntax `inline` is not really clear here, either. Maybe an attribute if
anything but I don't think this is very useful or should be standardized.
> 3. Run loop N times
> for ( 5 )
Why not just std::views::iota? I don't think it would be useful to make a
special-case syntax for such a thing. Even python decided against `for i in
5`.
Cheers,
Jeremy
On Fri, Mar 14, 2025 at 11:43 AM Filip via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> I want to ask for your comments about couple of different for loops ideas
> that I had recently:
>
> 1. using enum in for loop:
> ```
> for (auto e : someEnum) {...}
> ```
>
> Since compiler knows the elements of `ENUM` it should be able to easily
> unroll the loop or iterate over the elements of enum.
>
> 2. Forcing unroll with a keyword and not `#pragma`
> ```
> inline for ( … )
> ```
> It could force the unroll like similar construct does in zig.
> This syntax already exists and we could probably easily implement it.
>
> 3. Run loop N times
> ```
> for ( 5 )
> ```
> Running for loop N number of times is a common issue e.g. N tries to
> connect to the server.
> This way would not pollute the namespace with additional `int i` that we
> frankly don’t use.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-03-14 18:04:30