So I’m just watching https://www.youtube.com/watch?v=69pvUyBsruQ&t=2h15m19s and Simon Carter is referencing a difference between C compilers / platforms in the order of evaluating function arguments. So this makes me wonder:
Is this order defined in Zig? Is the following guaranteed?
functionCall(evaluatedFirst(), evaluatedSecond());
See also:
Thanks. That’s related, but does not seem to address the evaluation order of function arguments.
For instance, C’s comma operator , is defined as a sequence point
I did a quick search - “comma operator” is not referring to the comma used for delimiting function arguments.
Sze
August 29, 2026, 6:07pm
4
The part about the comma operator is talking about C, I think this part is more relevant:
As such, whilst I do not know if it has been formally defined at any point, I do expect Zig to ultimately include the status quo behavior in its spec, where sequencing of side effects always happens in the order of the source code (which I can confirm is guaranteed in the current compiler implementation, and in fact would be quite difficult for us to change due to how the compiler pipeline is structured).
3 Likes