mirror of https://github.com/golang/go.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
This commit is contained in:
parent
c91538f9c9
commit
f04ae1373e
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue