Are non-keyword, non-optional, function arguments guaranteed to be evaluated left-to-right?


#1

The section of the docs that deals with optional function arguments states (by my reading) that for any optional argument, all arguments to the left are guaranteed to be evaluated first and that optional argument default values are guaranteed to be evaluated left-to-right. This does not necessarily imply that non-optional, non-keyword, arguments are evaluated left-to-right. That is, for the function definition f(x, y, z=3), the statement is satisfied regardless of whether x or y is evaluated first, since z is the first optional argument.

I couldn’t actually find any statement that explicitly guarantees that non-keyword, non-optional, function arguments are guaranteed to be evaluated left-to-right so thought I would ask the question here.

Note, the reason I care is that for function calls such as f(read(io, x), read(io, y)), it will typically be very important that the first read is evaluated before the second read

Cheers,

Colin


#2

It is guaranteed but we never came up with an agreeable wording for the docs: https://github.com/JuliaLang/julia/pull/24603


#3

Ah, sorry, didn’t spot that issue in my googling.

Thanks,

Colin