2 ms·
Zig's inline for is also evaluated at comptime: https://ziglang.org/documentation/master/#inline-for https://ziglang.org/documentation/master/#inline-for
by ginko 5mo ago
Zig's inline for is also evaluated at comptime:
https://ziglang.org/documentation/master/#inline-for https://ziglang.org/documentation/master/#inline-for
- samatman 5mo agoWell yes, but the _effect_ is to unroll the loop for runtime, if the inline-for survives that long. A for loop executed during comptime is just const stuff = comptime stuff: { for (0...8) |i| { // etc, build up some stuff } break :stuff some_stuff; }; The difference is that a comptime block won't leave behind runnable 'residue', only whatever data is constructed for later. An inline for might not leave behind an unrolled loop either, but it can.