I'm curious: What's better about Swift's `defer` than `try/finally` in ObjC or Java (or virtually any other language since 1990)?
@mjtsai So it is a syntactical difference. Thanks. (AFAICT, this is the only significant difference besides cultural).
-
-
@iTod Yes, mainly the syntax is much more convenient and readable. And there is the codegen difference because it’s not based on exceptions. -
@mjtsai Hm, you're fist to mention that. Is `try/finally` (with no `catch`) significantly different from `defer` from a codegen perspective? -
@iTod Haven't looked at the assembly, but I would assume yes because try/finally has to essentially catch and rethrow the exception. -
@mjtsai Hm, that's interesting. So they're only different if an exception is thrown. But in non-exceptional case, it should be same as defer -
@iTod Yes, if we're talking about runtime behavior, and we have zero-cost exceptions. But I thought we were talking about codegen. -
@mjtsai Ah, right. Interesting.
-
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.
Todd Ditchendorf
Michael Tsai