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 How would you implement it? Remember "defer"red functions must execute at the end of the function, not end of block.
-
-
@pcwalton I haven't checked the assembly output (use go tool 6c -S FILE), but nothing gets evaluated in this case: http://play.golang.org/p/w12VUpT7ZP -
@PuerkitoBio I mean that "defer" has no runtime overhead when control flow encounters it, only when unwinding or exiting the function.
- 2 more replies
New conversation -
-
-
@pcwalton IOW there"s certainly a compiler and generated machine code overhead, but no runtime overhead. If that's what we're talking about?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.