Calls
If
f
denotes a generic function, it must be instantiated before it can be called or used as a function value.
We’ve seen this rule applied to methods and other types. It should be standard by now, so I won’t dwell on it.
In a function call, the function value and arguments are evaluated in the usual order. After they are evaluated, the parameters of the call are passed by value to the function and the called function begins execution. The return parameters of the function are passed by value back to the caller when the function returns.
We haven’t gotten to the “order of evaluation” yet, but a preview is in order. TL;DR; function parameters are evaluated in left-to-right order, then the function itself is called with the results. That means given the following function call:
a(b(), c(d(), e()))
The nested functions would be called in the following order:
- b
- d
- e
- c
- a
Quotes from The Go Programming Language Specification Version of August 2, 2023