<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 9, 2017, at 1:10 AM, Tyler Cloutier &lt;<a href="mailto:cloutiertyler@aol.com" class="">cloutiertyler@aol.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On Dec 26, 2016, at 2:55 PM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">on Mon Dec 26 2016, thislooksfun &lt;</span><a href="mailto:swift-evolution@swift.org" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">swift-evolution@swift.org</a><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">&gt; wrote:</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">Hello Swifters,<br class=""><br class="">I've been writing a lot more Swift code recently, and I have found<br class="">that the default placement of the 'throws' declaration is often<br class="">confusing, especially to those of us switching from languages where<br class="">the type of errors thrown is explicitly defined (like Java)<br class=""><br class="">For example,<br class="">// This is pretty clear, this can throw an error<br class="">func foo() throws<br class="">{ ... }<br class=""><br class="">// Also pretty clear, this returns a String<br class="">func bar() -&gt; String<br class="">{ ... }<br class=""><br class="">// Confusing. Does this throw a String? Does it return a String? Does it do both?<br class="">// I personally keep reading this as 'this can throw a String'<br class="">func baz() throws -&gt; String<br class=""><br class="">// Equivalent code in Java (not a model, just for clarification of why the above is confusing)<br class="">String baz() throws StringFormatException<br class="">I therefore suggest either tweaking the syntax around, or moving, the<br class="">`throws` keyword to avoid this confusion.<br class=""><br class="">Some ideas I've had:<br class="">// Add a comma to separate them<br class="">func baz() throws, -&gt; String<br class=""><br class="">// Move `throws` to the end<br class="">func baz() -&gt; String throws<br class=""></blockquote><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">I agree that reads much better.</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>baz() -&gt; (</span><span class="" style="color: rgb(0, 175, 202); font-variant-ligatures: no-common-ligatures;">String</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>|<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">throws</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="font-family: Helvetica; font-size: 12px;"><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;baz() -&gt; (</span><span class="" style="color: rgb(0, 175, 202); font-variant-ligatures: no-common-ligatures;">String</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;|&nbsp;</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">throws: BazError</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div></div><div class="" style="margin: 0px; line-height: normal;"></div></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>x: (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">_</span><span class="" style="color: rgb(255, 255, 255); font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">a:<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(0, 175, 202); font-variant-ligatures: no-common-ligatures;">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt;&nbsp; (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">throws</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>| (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">_</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>b: Float) -&gt; (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">throws</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>| Double))</span></div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><br class=""></div></div><div class="">Now where getting somewhere. Somewhere weird, to be sure… but somewhere.</div></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>Better yet, just add coproduct or union types, analogous to tuples, and it all seems to simplify.</div><div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;x: (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">_</span><span class="" style="color: rgb(255, 255, 255); font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">a:&nbsp;</span><span class="" style="color: rgb(0, 175, 202); font-variant-ligatures: no-common-ligatures;">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt; (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">Error</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;| (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">_</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;b: Float) -&gt; (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">Error</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;| Double))</span></div></div></div></div><div><div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;x: (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">_</span><span class="" style="color: rgb(255, 255, 255); font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">a:&nbsp;</span><span class="" style="color: rgb(0, 175, 202); font-variant-ligatures: no-common-ligatures;">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt; (</span><span class="" style="color: rgb(194, 52, 155); font-variant-ligatures: no-common-ligatures;">Error</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;| </span><span class="" style="font-variant-ligatures: no-common-ligatures;">Double)</span></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><div style="font-family: Helvetica; font-size: 12px;">No need to toss the try syntax either. It could be complementary.</div></div></div></div></div></div><div><br class=""></div><div><font face="Menlo" class="">let y = try! x(5)</font></div><div><font face="Menlo" class=""><br class=""></font></div><div><font face="Menlo" class="">let z = try? x(6)</font></div><div><font face="Menlo" class=""><br class=""></font></div><div><font face="Menlo" class="">let w = try x(8) catch { case(error: MyError) in</font></div><div><font face="Menlo" class=""><br class=""></font></div><div><font face="Menlo" class="">} catch { case(error: Error) in</font></div><div><font face="Menlo" class=""><br class=""></font></div><div><font face="Menlo" class="">}</font></div><div><font face="Menlo" class=""><br class=""></font></div><div><font face="Menlo" class="">switch x(7) {</font></div><div><font face="Menlo" class="">case(let e: Error): ...</font></div><div><font face="Menlo" class="">case(let x: Double): ...</font></div><div><font face="Menlo" class="">}</font></div><div><font face="Menlo" class=""><br class=""></font></div><div><div><font face="Menlo" class="">if case(let x: Double) = x(9) {</font></div><div><font face="Menlo" class=""><br class=""></font></div><div><font face="Menlo" class="">}</font></div><div class=""><br class=""></div></div><div>Obviously I’m going off on a tangent and I suppose my Scala is showing with those case pattern matches. Certainly a lot of directions to go here. One very sad thing here is it makes a seemingly ordinary type (Error) have magical (catch, try) syntax. This not meant to be taken too seriously, since I’m just avoiding going to sleep.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">// Change it to a prefix modifier (like `mutating`)<br class="">throwing func baz() -&gt; String<br class="">I'm still not sold on any of the above syntaxes, but I would love to hear your feedback.<br class=""><br class="">This would affect existing code, but it would be a fairly small change<br class="">that would result in very large readability improvements, especially<br class="">for newcomers, and especially for those coming for a language such as<br class="">Java.<br class=""><br class="">-thislooksfun (tlf)<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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><br class=""></blockquote><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">--<span class="Apple-converted-space">&nbsp;</span></span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">-Dave</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">_______________________________________________</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">swift-evolution mailing list</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><a href="mailto:swift-evolution@swift.org" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">swift-evolution@swift.org</a><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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;">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></blockquote></div><br class=""></body></html>