]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify defer semantics
authorRob Pike <r@golang.org>
Wed, 10 Oct 2012 02:29:50 +0000 (13:29 +1100)
committerRob Pike <r@golang.org>
Wed, 10 Oct 2012 02:29:50 +0000 (13:29 +1100)
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

doc/go_spec.html

index 165e9bebf2423191897feead91b11cf6f181228b..e7e6c78de5a09551ae6a1e94fb265aa21b672e3f 100644 (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