2 ms·
Exactly. You can also use non-comptime functions in comptime, if it avoids certain types of stateful behaviour.
by dnautics 6y ago
Exactly. You can also use non-comptime functions in comptime, if it avoids certain types of stateful behaviour.
- dinglejungle 6y agoAn example of this in the Zig math tests, where it tests calling the same function at both comptime and runtime: https://github.com/ziglang/zig/blob/33c4ad7f3a79aad5d7ea481ac98b42dc9f469076/lib/std/math.zig#L517-L527 https://github.com/ziglang/zig/blob/33c4ad7f3a79aad5d7ea481a...
- patrec 6y agoIn common-lisp you could do something equivalent, but you'd have to wrap the definitions you want to be able at both compile and and run time in eval-when.