@iTod I knew about it, but when there are multiple things to clean up, try/finally is so awkward that people use goto and multiple labels.
-
-
-
@mjtsai Hm, I'm surprised you think there's a significant awkwardness diff between try/finally & gotos with labelhttps://gist.github.com/itod/ae269e123cf94e42ccff … -
-
-
- View other replies
-
-
-
-
@iTod it's not that you cannot do it, it's that the amount of code needed to do it correctly is much greater and more error prone. - View other replies
-
@iTod also, try/finally only applies to exceptions, which is explicitly what errors are in Swift. You need to use NSError in ObjC. - View other replies
-
@owensd "Only applies to exceptions?" Maybe I don't follow, but no. I'm not talking about exceptional cases.https://gist.github.com/itod/bbc9c2ee250084e3b639 … - View other replies
-
@iTod though honestly, I'd flag code as bad code. Why are using exception handling code for non-exception handling circumstances? -
@owensd Strongly disagree, and this is my point. try/finally has important and perfectly reasonable applications for non-exceptional code. -
@iTod using try/finally outside of exceptions is confusing; defer gets you what you want without the cost or overloaded usage. -
@owensd 1) I disagree. This is somewhat common in Java land. 2) One could make an opposite "economy of constructs" argument for try/finally -
@iTod 1) this is ObjC, that code won't even compile for some people that have disabled exceptions. 2) There's no runtime cost for defer. - Show more
-
-
-
@iTod But… I thought it had to do with when it executes. Doesn’t defer wait until after the current scope is exited? Or… Uh… Stuff? - View other replies
-
@joesteel I guess this is my point. try/finally does the same thing (with different syntax), and no one seems to realize it. :)
-
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
David Owens II
evanlong
Joe Rosensteel