I just ported some code to OCaml and it was giving weird results. Not wrong just backwards. A quick inspection leads me to believe that (impure) code like Foo(x, y, z) -> Foo(r x, r y, r z) is being evaluated backwards, i.e. r z first.
Is there a switch or flag to control this? Or a preprocessor to make evaluation order explicit? I’d like evaluation order to be forwards for obvious reasons. I don’t want to mangle the code by hand because I’m planning on porting it to another language anyway.
No. Evaluation order in OCaml is officially undefined, but de facto right-to-left. The only alternative is to let-bind your arguments to make evaluation order explicit.