3 ms·
The problem is that comptime implies a full compile-time evaluation, while when doing an inline for you only want to unroll over a list of potentially heterogen
by kristoff_it 6y ago
The problem is that comptime implies a full compile-time evaluation, while when doing an inline for you only want to unroll over a list of potentially heterogeneous elements but the body of the for loop will remain available for evaluation at runtime, if not all vales are comptime known. In a comptime block that would cause a compile error.
I have an example of that in this blog post: https://kristoff.it/blog/what-is-zig-comptime/ https://kristoff.it/blog/what-is-zig-comptime/
- IshKebab 6y agoRight but it's just the `for` bit that's `comptime` right? The loop is unrolled and the loop condition must be `comptime`. It makes sense to me that `comptime for` means that the `for` is `comptime` but the body of the loop isn't.