This line of reasoning suggests an idea to me. Defer has the grammatical notion of "i want to do this later, but eventually, i don't want to forget to do it before i leave."
Imagine the slightly stronger notion of a "will" as in a person's last will and testament. Actions in your will are steps to be carried out in the event of your death. Presumably if an action has already been done during your lifetime, then that part of the will is mooted. Imagine a "will" statement in Go. Instead of Defer's chaining calls on the local function's return, the Will would do that with a wrapper that would set a bit saying "this has been done" but would also install a wrapper to the call on a global list owned by the runtime, which would inspect the bits at main's exit and call any functions that have not already been called. The function called at main's exit would be the 'executor' of the various wills. On Fri, Oct 6, 2017 at 1:08 AM, Mikhail Mazurskiy < mikhail.mazur...@gmail.com> wrote: > I wrote a library to help with this https://github.com/ash2k/stager > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Michael T. Jones michael.jo...@gmail.com -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.