Is there any way to implement Go-like "defer" in a zero-cost way, like RAII? I don't see any way to do it.
@PuerkitoBio I mean that "defer" has no runtime overhead when control flow encounters it, only when unwinding or exiting the function.
-
-
@pcwalton ah, ok, it does have an overhead because arguments are evaluated when `defer` is encountered. But then, it *will* get executed... -
@PuerkitoBio Via an indirect function call and a push onto a per-function list, no? RAII is direct function calls and no-per-function list.
End of conversation
New conversation -
-
-
@pcwalton (once encountered, a deferred function will necessarily execute, unless os.Exit or such abrupt termination)Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.