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

**URL:** <https://discourse.julialang.org/t/are-non-keyword-non-optional-function-arguments-guaranteed-to-be-evaluated-left-to-right/10293>\
**Category:** General Usage\
**Created:** [April 12, 2018, 2:07am UTC](https://discourse.julialang.org/t/are-non-keyword-non-optional-function-arguments-guaranteed-to-be-evaluated-left-to-right/10293 "2018-04-12T02:07:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![colintbowers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colintbowers/32/8033_2.png) [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Post date:** [April 12, 2018, 2:07am UTC](https://discourse.julialang.org/t/are-non-keyword-non-optional-function-arguments-guaranteed-to-be-evaluated-left-to-right/10293/1 "2018-04-12T02:07:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yurivish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yurivish/32/307_2.png) [@yurivish](https://discourse.julialang.org/u/yurivish)\
**Post date:** [April 12, 2018, 3:35am UTC](https://discourse.julialang.org/t/are-non-keyword-non-optional-function-arguments-guaranteed-to-be-evaluated-left-to-right/10293/2 "2018-04-12T03:35:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![colintbowers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colintbowers/32/8033_2.png) [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Post date:** [April 12, 2018, 4:21am UTC](https://discourse.julialang.org/t/are-non-keyword-non-optional-function-arguments-guaranteed-to-be-evaluated-left-to-right/10293/3 "2018-04-12T04:21:26Z")

</div>

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

Thanks,

Colin
