From: Rob Pike Date: Wed, 10 Oct 2012 02:29:50 +0000 (+1100) Subject: spec: clarify defer semantics X-Git-Tag: go1.1rc2~2166 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f04ae1373eb75fc63a35b81f7d1b3d5867523279;p=gostls13.git spec: clarify defer semantics It's already there but only in the "for instance" and so not clear enough: deferred functions run after the result parameters are updated. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/6631058 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 165e9bebf2..e7e6c78de5 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -4726,7 +4726,8 @@ and saved anew but the actual function is not invoked. Instead, deferred calls are executed in LIFO order immediately before the surrounding function returns, -after the return values, if any, have been evaluated, but before they +after the return values, if any, have been evaluated and assigned +to the result parameters, but before they are returned to the caller. For instance, if the deferred function is a function literal and the surrounding function has named result parameters that