[swift-users] Swift error management - investigate what's behind

Jan Neumüller nasan at slayers.de
Mon Mar 6 11:43:53 CST 2017


Important point is: Swift has no exceptions…

From the Swift manual at apple:
Error handling in Swift resembles exception handling in other languages, with the use of the try, catch and throw keywords. Unlike exception handling in many languages—including Objective-C—error handling in Swift does not involve unwinding the call stack, a process that can be computationally expensive. As such, the performance characteristics of a throw statement are comparable to those of a return statement.


> On 6 Mar 2017, at 14:35, Jérôme Duquennoy via swift-users <swift-users at swift.org> wrote:
> 
> Hi guys,
> 
> I am right now building a presentation of the swift error management system for some of my colleagues.
> I can explain how it works from a dev’s standpoint, and how it interacts with obj-c. But I would like to have a deeper understanding of it, and notably to understand what the compiler does when a do … try block is found, how it knows that there is such a block at the current level of the stack and jumps to it, …
> I have notably noticed that exceptions are much slower than a simple “return” when building without optimisation, while it is just as fast when optimisations are enabled. I would like to understand what causes that difference.
> 
> Sadly, I have not dived into the sources of swift up to now, which makes the beginning of the investigation a bit hard.
> Could anyone point me to some starting place where I could begin ?
> 
> Thanks for your help !
> 
> Jerome
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170306/a98a315d/attachment.html>


More information about the swift-users mailing list