In OCaml, evaluation order of function application is unspecified (aka non-deterministic).
In Standard ML, is it also non-deterministic or deterministic? Can you provide a reference to the spec section that clarifies?
Edit: for those of you coming later, I also learned that like SML, in F# the order is specified and deterministic--unlike OCaml, which is even more crazy considering how close the two are in syntax. Easy to forget if you switch between them a lot.
Yes, the evaluation rules (Section 6.7 of the Definition) fully specify evaluation order for all constructs of SML, and it always is in textual order. For application, first the function expression is evaluated and then the argument (e.g. rule 102). Similarly, records (and thus tuples) are evaluated left-to-right (rules 92/95).
Together, that implies that e.g. f(a,b)(c,d)
is evaluated in the order f
, a
, b
, f(...)
, c
, d
, g(...)
, where g
is the result of f(...)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With