3 ms·
Swift has a nice middle-ground here. Functions which can throw must be marked as such, and if you call a throwing function, you must use the `try` keyword. You
by TazeTSchnitzel 11y ago
Swift has a nice middle-ground here. Functions which can throw must be marked as such, and if you call a throwing function, you must use the `try` keyword. You don't actually have to handle the error there (you can let it propagate, or choose to let the program crash), but you can if you want.
This means there's no implicit control flow. You can always see where a function might throw, or know that a function will never throw. It also means, performance-wise, the implementation is much more efficient than C++-style stack unwinding.
I've not used this in practice, because I've not tried Swift, but I think it's a good approach.
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ErrorHandling.html https://developer.apple.com/library/prerelease/ios/documenta...