From 633a2ce096464a63d939c645f31c6bf9d245b042 Mon Sep 17 00:00:00 2001
From: Rob Pike
The expression must be a function or method call.
Each time the "defer" statement
-executes, the parameters to the function call are evaluated and saved anew but the
-function is not invoked.
-Deferred function calls are executed in LIFO order
+executes, the function value and parameters to the call are
+evaluated as usual
+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
are returned to the caller. For instance, if the deferred function is
@@ -4503,6 +4527,8 @@ a function literal and the surrounding
function has named result parameters that
are in scope within the literal, the deferred function may access and modify
the result parameters before they are returned.
+If the deferred function has any return values, they are discarded when
+the function completes.
@@ -5355,9 +5381,7 @@ A struct or array type has size zero if it contains no fields (or elements, resp
len(a)
is only a constant if a
is a (qualified) identifier denoting an array or pointer to an array.len(x)
is only a constant if x
is a (qualified) identifier denoting an array or pointer to an array.