<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Don,<div class=""><br class=""></div><div class="">This is just my opinion, but I prefer the explicit 'try' on each statement that can throw, because then it is easier to see where all the early returns are from a function, in case any resources have to be cleaned up with a 'defer'.</div><div class=""><br class=""></div><div class="">Slava</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 6:30 AM, Don Arnel via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Is there a reason this format was adopted for error handling:<div class=""><ol class="code-lines" style="border: 0px; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; counter-reset: li 0; line-height: 1.6em; list-style: none; font-family: Helvetica, Arial, sans-serif;"><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><br class=""></li></ol></div><div class=""><ol class="code-lines" style="border: 0px; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; counter-reset: li 0; line-height: 1.6em; list-style: none; font-family: Helvetica, Arial, sans-serif;"><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">do</span> {</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"> <span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">try</span> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">makeASandwich</span>()</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">eatASandwich</span>()</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;">} <span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">catch</span> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">Error</span>.<span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">OutOfCleanDishes</span> {</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">washDishes</span>()</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -17px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;">} <span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">catch</span> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">Error</span>.<span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">MissingIngredients</span>(<span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">let</span> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">ingredients</span>) {</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -17px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">buyGroceries</span>(<span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">ingredients</span>)</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -17px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;">}</code></li></ol><div class=""><br class=""></div></div><div class="">rather than this format:</div><div class=""><br class=""></div><div class=""><ol class="code-lines" style="border: 0px; font-size: 14px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; counter-reset: li 0; line-height: 1.6em; list-style: none; font-family: Helvetica, Arial, sans-serif;"><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"><span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">try</span> {</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">makeASandwich</span>()</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">eatASandwich</span>()</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;">} <span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">catch</span> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">Error</span>.<span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">OutOfCleanDishes</span> {</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -13px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">washDishes</span>()</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -17px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;">} <span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">catch</span> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">Error</span>.<span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">MissingIngredients</span>(<span class="kt" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(170, 51, 145);">let</span> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">ingredients</span>) {</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -17px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;"> <span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">buyGroceries</span>(<span class="vc" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(63, 110, 116);">ingredients</span>)</code></li><li style="border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; text-indent: -17px; white-space: pre-wrap; list-style-type: none;" class=""><code class="code-voice" style="border: 0px; font-size: 0.85em; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; font-family: Menlo, monospace; word-wrap: break-word;">}</code></li></ol><div class=""><br class=""></div></div><div class="">The second format is much more intuitive, and reads easier IMO.</div><div class=""><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=NLTid1W7V2mxBEfr5Y3KfTntaxSmOQp5vjACZc9Eh1-2FMajA5TXR1HuZAnQ3PJL-2FTcJuYfsjKv7MECa-2BM3OuJdNpOzgBGI-2FtG25v7It7uhf9Ez5wgRzKQA2B0x8EF-2B3tMCG58W890tHgsBs8cIwI-2BLHobT5f0vi0NA0vIV3zigZRGOAadNpZgRHpNC5JU2yWnC62nfKw7MuKsC4WRPf8vXyUDVIi1sjwnBFQmL1PfvNM-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>