Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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/



Right 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: