<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Important point is: Swift has no exceptions…<div class=""><br class=""></div><div class="">From the Swift manual at apple:</div><div class=""><div class="note" style="background-color: rgb(249, 249, 249); border-width: 0px 0px 0px 5px; border-left-style: solid; border-left-color: rgb(233, 233, 233); font-size: 1.2em; margin: 30px auto 35px; outline: 0px; padding: 15px 15px 7px; vertical-align: baseline; width: 581.390625px; font-family: Helvetica, Arial, sans-serif;"><aside class="aside"><p class="para" style="background-color: transparent; border: 0px; font-size: 0.75rem; margin: 0px 0px 8px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(65, 65, 65); line-height: 17.399999618530273px; background-position: initial initial; background-repeat: initial initial;">Error handling in Swift resembles exception handling in other languages, with the use of the&nbsp;<code class="code-voice" style="background-color: transparent; border: 0px; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(128, 128, 128); font-family: Menlo, monospace; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">try</code>,&nbsp;<code class="code-voice" style="background-color: transparent; border: 0px; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(128, 128, 128); font-family: Menlo, monospace; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">catch</code>&nbsp;and&nbsp;<code class="code-voice" style="background-color: transparent; border: 0px; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(128, 128, 128); font-family: Menlo, monospace; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">throw</code>&nbsp;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&nbsp;<code class="code-voice" style="background-color: transparent; border: 0px; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(128, 128, 128); font-family: Menlo, monospace; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">throw</code>&nbsp;statement are comparable to those of a&nbsp;<code class="code-voice" style="background-color: transparent; border: 0px; font-size: 0.9em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(128, 128, 128); font-family: Menlo, monospace; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">return</code>&nbsp;statement.</p></aside></div><section class="section" style="padding: 0px; margin: 30px 0px 0px; font-family: Helvetica, Arial, sans-serif; font-size: 10px;"></section>
<br class=""><div><blockquote type="cite" class=""><div class="">On 6 Mar 2017, at 14:35, Jérôme Duquennoy via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi guys,<br class=""><br class="">I am right now building a presentation of the swift error management system for some of my colleagues.<br class="">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, …<br class="">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.<br class=""><br class="">Sadly, I have not dived into the sources of swift up to now, which makes the beginning of the investigation a bit hard.<br class="">Could anyone point me to some starting place where I could begin ?<br class=""><br class="">Thanks for your help !<br class=""><br class="">Jerome<br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></div></blockquote></div><br class=""></div></body></html>