From f04ae1373eb75fc63a35b81f7d1b3d5867523279 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Wed, 10 Oct 2012 13:29:50 +1100 Subject: [PATCH] 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 --- doc/go_spec.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 -- 2.48.1