Y
Hacker News
new
|
ask
|
show
|
jobs
by
creata
2064 days ago
Can you please provide an example of Zig "working out the dependency"? I'm struggling to make sense of your comment.
1 comments
patrec
2064 days ago
I could write a concrete example that will work in zig and fail in common lisp, but maybe this link is enough?
https://ziglang.org/#Order-independent-top-level-declaration...
link
creata
2064 days ago
Oh, so is the point that in Zig, functions with comptime parameters are more or less identical to regular functions in that regard?
link
dnautics
2064 days ago
Exactly. You can
also
use non-comptime functions in comptime, if it avoids certain types of stateful behaviour.
link
dinglejungle
2063 days ago
An 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/33c4ad7f3a79aad5d7ea481a...
link
patrec
2063 days ago
In 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.
link
https://ziglang.org/#Order-independent-top-level-declaration...