-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hello, I like the idea of a generic close-to-C AST representation, however there seems to be no mention of evaluation order in the specification for nested expressions with side effects.
I tried the following NIF source:
(.nif24)
(stmts
(proc :main.c . (i +32) .
(stmts
(call fn2.c (call fn.c "foo") (call fn.c "bar"))
)))
From which the C backend of nifc generates:
NI32 main(void) { fn2(fn("foo"), fn("bar")); }
In C, the ordering of arguments to functions and most binary operators is left implementation-defined, so at least for the C backend, there are chances that programs written in NIF will behave differently across systems. In fact, the two fn() calls in above example are compiled in opposite order by current GCC and Clang https://godbolt.org/z/s1GoKrGcE.
For NIF's goal to be a language agnostic communication format, leaving this undefined, even if just one backend, seems to be a bit of a loose end. Would you consider a stricter evaluation order in the NIF specification?