Commit f04ae137 authored by Rob Pike's avatar Rob Pike

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
parent c91538f9
<!--{
"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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment