const ENDIAN = builtin.cpu.arch.endian();
fn foo() void {
if (ENDIAN == std.builtin.Endian.little) {
// some runtime codes
} else {
// some runtime codes
}
}
well, i think if (ENDIAN == std.builtin.Endian.little) will turn into if (true) or if (false) and compiler will be able to optimize it away…
but what if I had some switch cases based on some comptime variable, in that case will the compiler only generate the specific function body depending on that condition? or it will generate all the cases lazily?
I didn’t quite get the each branch is evaluated part fn square(num: i32) i32 the num is a runtime argument right? how does it get evaluated at comptime?