/* * A program to investigate the order of evaluation of actual args * to a function in Go. * While every test I run says it is right to left, as does this program, * the language docs are mum, so there is no guarantee of L-R * * @author gtowell * created: July 29, 2021 */ package main import "fmt" var a int /* * Increment the global variable a by 7 * @return the value of the global a */ func a7() int { a+=7 return a; } /* * Multiply the global var a by 13 * @return the value of a */ func a13() int { a *= 13 return a; } /* * Print the value of the the two passes args * @param a2 an integer * @param a3 another integer */ func b(a2 int, a3 int) { fmt.Printf("B %d %d\n", a2, a3) } func main() { for i:=0; i<20; i++ { b(a13(), a7()) a=0 // reset the value of a after each loop } b(a7(), a13()) // reverse the functions }