]> Cypherpunks repositories - gostls13.git/commit
spec: clarify returns, defer statements, and panics
authorRobert Griesemer <gri@golang.org>
Thu, 1 Nov 2012 17:13:48 +0000 (10:13 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 1 Nov 2012 17:13:48 +0000 (10:13 -0700)
commit1e8e14c901cebde0550c4fe0c1a77b3902d6080d
treeaadb983f97d4baf300c2c1cd5c20cf95760afaaf
parent5c1422afabb7efa26b382e818314748bb8c857d9
spec: clarify returns, defer statements, and panics

This is an attempt at making the interaction between
these three constructs clearer. Specifically:

- return statements terminate a function, execute deferred
  functions, return to the caller, and then execution
  continues after the call

- panic calls terminate a function, execute deferred
  functions, return to the caller, and then re-panic

- deferred functions are executed before a function _returns_
  to its caller

The hope is that with this change it becomes clear when a
deferred function is executed (when a function returns),
and when it is not (when a program exits).

R=r, rsc, iant, ken, iant
CC=golang-dev
https://golang.org/cl/6736071
doc/go_spec.html