|
|
|
|
|
by int_19h
426 days ago
|
|
The point is that something like sizeof(pointer) should have the same value in comptime code that it has at runtime for a given app. Which, yes, means that the comptime interpreter emulates the target machine. The reason is fairly simple: you want comptime code to be able to compute correct values for use at runtime. At the same time, there's zero benefit to not hiding the host platform in comptime, because, well, what use case is there for knowing e.g. the size of pointer in the arch on which the compiler is running? |
|
Reasonable if that’s how it works. I had absolutely no idea that Zig comptime worked this way!
> there's zero benefit to not hiding the host platform in comptime
I don’t think this is clear. It is possibly good to hide host platform given Zig’s more limited comptime capabilities.
However in my $DayJob an extremely common and painful source of issues is trying to hide host platform when it can not in fact be hidden.