<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=""><div class="">Indeed both are reasonable but perhaps suboptimal. Consider the following potential changes.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;" class="">// Assume this code is included for the below examples.</span></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> myThrowingFunc() <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">throws</span> -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span> {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">drand48</span>() &lt; <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0.5</span> {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">throw</span> <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSError</span>(domain: <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span>, code: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>, userInfo: <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">nil</span>)</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; min-height: 13px;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class="">let</span>&nbsp;str:&nbsp;<span style="color: rgb(112, 61, 170);" class="">String</span></div></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><br class=""></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><br class=""></div></div></div><div class="">The current syntax is very clear and straightforward.&nbsp;</div><div class=""><br class=""></div><div class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">// Current syntax</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class="">do</span>&nbsp;{</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(49, 89, 93);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(79, 129, 135);" class="">str</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;=&nbsp;</span><span style="color: rgb(187, 44, 162);" class="">try</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;</span>myThrowingFunc<span style="color: rgb(0, 0, 0);" class="">()</span><span style="color: rgb(0, 0, 0);" class="">.</span><span style="color: rgb(61, 29, 129);" class="">stringByAppendingString</span><span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(209, 47, 27);" class="">"appended"</span><span style="color: rgb(0, 0, 0);" class="">)</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class=""><span style="color: rgb(0, 0, 0);" class="">}&nbsp;</span>catch<span style="color: rgb(0, 0, 0);" class="">&nbsp;{</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(79, 129, 135);" class="">str</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;=&nbsp;</span>"Default"</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(61, 29, 129);" class="">print</span><span style="color: rgb(0, 0, 0);" class="">(</span>"caught!"<span style="color: rgb(0, 0, 0);" class="">)</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}</div></div><div class=""><br class=""></div><div class="">There are two potential issues with it however. The first is that it is quite verbose, and the second is that the try is actually marking two function calls, one which throws and one which does not. In this fake example it’s clear that myThrowingFunc throws, but in general&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;is not marking a single point of failure.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">One change might be to simply rename <font color="#bb2ca2" face="Menlo" class=""><span style="font-size: 11px;" class="">do</span></font>&nbsp;blocks that can throw to&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;blocks.&nbsp;</div><div class=""><br class=""></div><div class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">// Create try blocks which encapsulate potentially throwing code.</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class="">try<span style="color: rgb(0, 0, 0);" class="">&nbsp;{</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(49, 89, 93);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(79, 129, 135);" class="">str</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;=&nbsp;</span><span style="color: rgb(187, 44, 162);" class="">try</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;</span>myThrowingFunc<span style="color: rgb(0, 0, 0);" class="">()</span><span style="color: rgb(0, 0, 0);" class="">.</span><span style="color: rgb(61, 29, 129);" class="">stringByAppendingString</span><span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(209, 47, 27);" class="">"appended"</span><span style="color: rgb(0, 0, 0);" class="">)</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class=""><span style="color: rgb(0, 0, 0);" class="">}&nbsp;</span>catch<span style="color: rgb(0, 0, 0);" class="">&nbsp;{</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(79, 129, 135);" class="">str</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;=&nbsp;</span>"Default"</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(61, 29, 129);" class="">print</span><span style="color: rgb(0, 0, 0);" class="">(</span>"caught!"<span style="color: rgb(0, 0, 0);" class="">)</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}</div></div><div class=""><br class=""></div><div class="">The motivation for doing this would be to clarify the difference between blocks that can throw and blocks that can’t. For example, it’s helpful to not have to scroll to the bottom of a long block to find catch, or scan through all the lines to find the try keyword for a long block. You would be able to see just from&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;that block was throwing. It would also be similar to many other languages that use&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;to demarcate throwing blocks. The problems with this are that it could be considered redundant, and is even more verbose (by 1 character) than the current syntax. Furthermore, as with the current syntax,&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;is not marking a single point of failure (and yet now we have to&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;keywords).</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Another change could be to rename&nbsp;<font color="#bb2ca2" face="Menlo" class=""><span style="font-size: 11px;" class="">do</span></font>&nbsp;blocks that can throw to&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;blocks and then not require explicit marking of&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;on throwing statements.</div><div class=""><br class=""></div><div class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">// Don't require explicit try marking within try blocks.</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class="">try<span style="color: rgb(0, 0, 0);" class="">&nbsp;{</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(49, 89, 93);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(79, 129, 135);" class="">str</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;=&nbsp;</span>myThrowingFunc<span style="color: rgb(0, 0, 0);" class="">()</span><span style="color: rgb(0, 0, 0);" class="">.</span><span style="color: rgb(61, 29, 129);" class="">stringByAppendingString</span><span style="color: rgb(0, 0, 0);" class="">(</span><span style="color: rgb(209, 47, 27);" class="">"appended"</span><span style="color: rgb(0, 0, 0);" class="">)</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(187, 44, 162);" class=""><span style="color: rgb(0, 0, 0);" class="">}&nbsp;</span>catch<span style="color: rgb(0, 0, 0);" class="">&nbsp;{</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(79, 129, 135);" class="">str</span><span style="color: rgb(0, 0, 0);" class="">&nbsp;=&nbsp;</span>"Default"</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(61, 29, 129);" class="">print</span><span style="color: rgb(0, 0, 0);" class="">(</span>"caught!"<span style="color: rgb(0, 0, 0);" class="">)</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}</div></div><div class=""><br class=""></div><div class="">This approach retains all of the benefits of the above change, including familiarity for those coming from other languages. Also, it no longer requires the redundant double&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;syntax. In this case&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span>&nbsp;is not assumed to be marking a single potentially failing call, but a group of them. Unfortunately, this means that it might not be clear which function is the function that can throw, in a block of code. However, this is already somewhat the case for chained calls in the current syntax. Certainly, only allowing this ambiguity for chained calls reduces the potential size of the code that is unmarked, with functional paradigms long chains are not so uncommon.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The final change that I have included above is really just a shortening of syntax and could be applied to any of the above implementations to reduce verbosity.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">// Allow catch directly on try expression.</div><div style="margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;str =&nbsp;</span><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;</span><font color="#31595d" face="Menlo" class=""><span style="font-size: 11px;" class="">myThrowingFunc</span></font><span style="font-family: Menlo; font-size: 11px;" class="">()</span><span style="font-family: Menlo; font-size: 11px;" class="">.</span><span style="color: rgb(61, 29, 129); font-family: Menlo; font-size: 11px;" class="">stringByAppendingString</span><span style="font-family: Menlo; font-size: 11px;" class="">(</span><span style="color: rgb(209, 47, 27); font-family: Menlo; font-size: 11px;" class="">"appended</span><font color="#d12f1b" face="Menlo" class=""><span style="font-size: 11px;" class="">”</span></font><font face="Menlo" class=""><span style="font-size: 11px;" class="">)&nbsp;</span></font><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">catch</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;{</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(49, 89, 93);" class=""><span style="color: rgb(0, 0, 0);" class=""></span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;str =&nbsp;<span style="color: rgb(209, 47, 27);" class="">"Default"</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span style="color: rgb(0, 0, 0);" class="">&nbsp; &nbsp;&nbsp;</span><span style="color: rgb(61, 29, 129);" class="">print</span><span style="color: rgb(0, 0, 0);" class="">(</span>"caught!"<span style="color: rgb(0, 0, 0);" class="">)</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}</div><div class=""><br class=""></div><div class="">This also has the added benefit of not having to open up a new scope just to catch an error. Additionally it’s very easy to refactor into a&nbsp;<span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">try?</span>&nbsp;statement.</div><div class=""><br class=""></div></div></div><div class="">I’d really like to see how these changes might affect real world examples and if I get some time, I will look for some and share them with the list. That way we can really see what the effects of these changes would be within the context of an actual use case.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">What would you think about a solution that just inverted the default. &nbsp;Rather than marking throwing expressions with `try` we could have a try block (with optional catch clauses) where non-throwing calls are marked with `do`. &nbsp;The primary motivation for requiring `do` would be to prevent abuse of `try` blocks by making them awkward when there is a reasonable mix of throwing and non-throwing code. &nbsp;A secondary benefit is that would still be clear what can throw and what can’t, although this is much less useful when most things can throw.</blockquote><br class=""></div><div class=""><div class="">Also Matthew, I think this is an interesting idea. And I’d say you’ve hit on the major problem with try blocks, potential excessive mixing of throwing and non throwing code. You could perhaps enforce that try blocks must begin and end with a potentially throwing statement to cut down on mixing, but people might find that strange/confusing.</div></div><div class=""><br class=""></div><div class="">Tyler</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 3, 2016, at 11:37 AM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" class="">dabrahams@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On Jan 3, 2016, at 10:21 AM, Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class=""><br class="">On Jan 3, 2016, at 12:12 PM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Jan 2, 2016, at 2:23 PM, Tyler Cloutier &lt;<a href="mailto:cloutiertyler@aol.com" class="">cloutiertyler@aol.com</a>&gt; wrote:<br class=""><br class="">Please see comments inline.<br class=""><br class=""><blockquote type="cite" class="">On Dec 31, 2015, at 12:07 PM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On Dec 27, 2015, at 10:25 PM, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">So “try” instead of “do”. If there is no catch, then just use braces without a keyword for a block.<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">And use do-while instead of repeat-while.<br class=""></blockquote></blockquote><br class="">+1<br class=""><br class=""><blockquote type="cite" class=""><br class="">Do you also propose no longer marking calls to throwing functions with `try`?<br class=""></blockquote><br class="">If try had both a single-statement/expression form as it does today, and a block form that makes it unnecessary to mark all the individual statements in the block, that would be an improvement.<br class=""><br class=""><blockquote type="cite" class="">Have you read the "Error-Handling Rationale" document in the Swift repository? If not, please do: &lt;<a href="https://github.com/apple/swift/blob/master/docs/ErrorHandlingRationale.rst" class="">https://github.com/apple/swift/blob/master/docs/ErrorHandlingRationale.rst</a>&gt; If so, please explain why you disagree with it.<br class=""></blockquote><br class="">There are large classes of programs where you can know you don’t care exactly where a failure happens, e.g. (most init functions, all pure functions, any function that doesn’t break invariants). &nbsp;In these cases marking every statement or expression that can throw is just noise. &nbsp;Try writing some serialization/deserialization code where the underlying stream can fail to see what I mean; you’ll have “try” everwhere, and it adds nothing to comprehensibility or maintainability. &nbsp;Personally I would like to be able to label the function itself and not have to introuce a scope, but IMO being able to create “try blocks” would be a welcome addition and would even match the common case in blocks with catch clauses, where being aware of the exact line where the error was generated is typically not useful.<br class=""></blockquote><br class="">I had proposed something very similar to this around six months ago on the swift-users list, but I think John McCall, had some (quite valid) concerns with this.<br class=""><br class="">Unfortunately I can't access those emails, but I think his concern was that the purpose of try was to mark explicitly which statements throw and this would defeat the purpose of that. People might just wrap large blocks in try.<br class=""></blockquote><br class="">As much as I am loath to disagree with John on this, there’s an incorrect implicit assumption in that rationale, that forcing people to mark all throw points trains them to get error-handling correct. &nbsp;What it does instead is to train them to think of all code uniformly instead of recognizing the places where a throw needs special attention (places where there are broken invariants). Eventually, as with warnings that have a high false-positive rate, when you see “try” in many places where it doesn’t help, you learn to ignore it altogether.<br class=""></blockquote><br class="">I agree that requiring this is not likely to result in improved error handling and thus is not a strong argument in favor of it.<br class=""><br class="">IMO the purpose of requiring “try” to be stated explicitly is that it arguably makes code more readable. &nbsp;It is immediately clear which functions can throw and which cannot. &nbsp;You don’t need to look up the signature of every function called to determine this. My experience thus far has been that I have really appreciated the requirement that throwing expressions be explicitly marked.<span class="Apple-converted-space">&nbsp;</span><br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">As a default it’s great. &nbsp;Not having a way to opt out of individual marking for a whole block or function—because you know you’re not breaking any invariants, so which functions can throw is irrelevant, and not having a way for the compiler deduce these regions (e.g. known pure functions)—is the problem. &nbsp;The recognizer code posted in an earlier message is a perfect example. &nbsp;If there *was* some code where it was really important to notice failure points, you’d miss it.<span class="Apple-converted-space">&nbsp;</span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">The key to getting error handling right is not being able to trace every possible control path—which is effectively impossible anyway— it’s understanding the relationship between scopes in your code and your program’s invariants. &nbsp;</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I think positions on both sides of this are reasonable.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Absolutely. &nbsp;Even reasonable positions can be sub-optimal though :-)</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class=""><br class="">Another idea is to treat the block as an unnamed, no argument, no return value, function that could throw. This solves the problem in a very general way, and would retain the marking of all throwing functions with try,<br class=""></blockquote><br class="">That marking, in itself, is the root problem. &nbsp;Our syntax is the way it is primarily because "marking everywhere" was adopted as an explicit goal.<br class=""><br class=""><blockquote type="cite" class="">but has the perhaps unfortunate syntax of allowing things like:<br class=""><br class="">try {<br class="">try myFunction()<br class="">} catch {<br class=""><br class="">}<br class=""><br class="">Something like this could be shortened to a consistent theoretical inline try catch syntax like:<br class=""><br class="">try myFunction() catch {<br class=""><br class="">}<br class=""><br class="">Though, as John, pointed out at the time, this could still be added on with the current syntax. Obviously treating a try like an unnamed function would have different return semantics, so perhaps that's not the right abstraction. (Although I recall a thread going on that is considering allowing functions to retain return semantics of the outer scope)<br class=""><br class="">Tyler<br class=""><br class=""><br class=""><blockquote type="cite" class=""><br class="">-Dave<br class=""><br class="">_______________________________________________<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=""></blockquote></blockquote><br class="">-Dave<br class=""><br class="">_______________________________________________<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=""></blockquote></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">-Dave</span></div></blockquote></div><br class=""></body></html>