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.
@samth func Foo() { ... if bar() { defer baz(); } ... /* baz() only runs here if bar() evaluated to true */ }
-
-
@pcwalton I'm pretty sure this *is* zero-cost at runtime if bar() is false. You're saying it isn't? -
@PuerkitoBio How would you implement it? Remember "defer"red functions must execute at the end of the function, not end of block.
- 4 more replies
New conversation -
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.