It looks like the language spec is a little imprecise in the Order of evaluation <https://golang.org/ref/spec#Order_of_evaluation> section about if any function evaluating an index of a slice will always be invoked before anything is done to the slice at that index. That is, if you have something like: mySlice[someFunc()] = 45 is someFunc() guaranteed to be called before the value at the int it returns is set to 45?
I created a sample test and ran it on 32 different kinds of machines (using Travis CI), including 8 different versions of Go, two different architectures, and two operating systems. Here is the code: https://github.com/dchenk/go-eval-order And here are the test results: https://travis-ci.org/dchenk/go-eval-order/builds/335042572 So what are the guarantees, if there are any, about the evaluation order of the inner function verses the slice indexing operation? I want to make sure invalid indexing isn't possible in the kind of code on line 10 in the main.go file in the repo linked to above. Thanks! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.