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
This commit is contained in:
Rob Pike 2012-10-10 13:29:50 +11:00
parent c91538f9c9
commit f04ae1373e
1 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of October 3, 2012",
"Subtitle": "Version of October 10, 2012",
"Path": "/ref/spec"
}-->
@ -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 <a href="#Function_literals">function literal</a> and the surrounding
function has <a href="#Function_types">named result parameters</a> that