<div dir="ltr">On Mon, Dec 26, 2016 at 2:20 PM, Tony Allevato via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&quot;throws&quot; makes more sense closer to the end of the function signature because it&#39;s an outcome like the return type. Swift&#39;s function syntax is fairly consistent in this regard: &lt;modifiers&gt; func &lt;name&gt;(&lt;inputs&gt;) &lt;outcomes&gt;.<br><br>Personally, I think the keyword is fine where it is and this is the kind of change where there would have to be *significant* advantages to changing it. I think it would be hard to make the case that a change at this point would warrant breaking existing code.</blockquote><div><br></div><div>In a vacuum, I too would probably lean towards `throws` being closer to the end of the signature than it is now, but that&#39;s kind of beside the point.</div><div><br></div><div>As a meta-comment, although this syntax was introduced prior to the evolution process, one must expect that the core team debated between all obvious options and chose the current one over the alternatives. Even before the current point where source-breaking changes need &quot;extreme&quot; justification, it would have required significant motivation consisting of, say, empirical evidence of frequently incorrect code, etc., to justify a change. The bar for revisiting previous decisions is and justifiably should be very high; in the recent past, it&#39;s generally taken place due to glaring difficulties found during implementation that could not be fixed without amending a previous proposal.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div class="gmail_quote"><div dir="ltr">On Mon, Dec 26, 2016 at 10:59 AM Lucas Neiva via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg"><span style="background-color:rgba(255,255,255,0)" class="m_-5171550767766731285gmail_msg">I like &quot;throwing&quot; as a prefix. It&#39;s reads well and fits very nicely with &quot;mutating&quot;.</span></div><div class="m_-5171550767766731285gmail_msg"><span style="background-color:rgba(255,255,255,0)" class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></span></div><div class="m_-5171550767766731285gmail_msg"><span style="background-color:rgba(255,255,255,0)" class="m_-5171550767766731285gmail_msg">Remembering where to put the keyword for is also easier if it&#39;s at the beginning, where it fits grammatically as &quot;throwing func&quot;.</span></div></div></div><div dir="auto" class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">On 26 Dec 2016, at 19:53, Micah Hainline via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_-5171550767766731285gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><blockquote type="cite" class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">I&#39;d prefer the placement at the very end, I do think it would improve readability, especially when taking closures as parameters and returning closures. However, I don&#39;t think the value would be worth the cost of breaking existing code. At the least if this were to go forward I would think we&#39;d want both styles to work even if one was preferred or the other was deprecated. </div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">On Dec 26, 2016, at 12:41 PM, Derrick Ho via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_-5171550767766731285gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><blockquote type="cite" class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg">I personally do not see anything wrong with its current placement.<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">It may be there because it was based on an existing cocoa pattern from objective-c<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">- (NSString *)bazWithError:(NSError **)error { ... }</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">Because objective c could only return one thing, using pointer-to-pointer was needed to deliver more than one.</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">When swift came along it became this...</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">func baz(error: NSErrorPointer) -&gt; String</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">The style felt old-fashioned and was replaced with throw.</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">func baz() throws -&gt; String</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">The evolution is consistent.  The pattern is familiar.  I think we should keep the placement of throw as it is.</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><div class="gmail_quote m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg">On Mon, Dec 26, 2016 at 9:38 AM thislooksfun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_-5171550767766731285gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_-5171550767766731285gmail_msg"></div><blockquote class="gmail_quote m_-5171550767766731285gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="m_-5171550767766731285gmail_msg">Hello Swifters,<div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">I&#39;ve been writing a lot more Swift code recently, and I have found that the default placement of the &#39;throws&#39; declaration is often confusing, especially to those of us switching from languages where the type of errors thrown is explicitly defined (like Java)</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">For example,</div><div class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285m_2577537579941429844m_7524104568081187879m_-7031938144007969227bloop_markdown m_-5171550767766731285gmail_msg" style="font-family:Helvetica,Arial;font-size:13px;background-color:rgb(254,254,254)"><pre style="margin-top:15px;margin-bottom:15px;font-family:Menlo,Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);color:inherit;border:1px solid rgb(204,204,204);overflow:auto;padding:4px 8px;word-break:normal;word-wrap:normal" class="m_-5171550767766731285gmail_msg">// This is pretty clear, this can throw an error<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">func foo() throws<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">{ ... }<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">// Also pretty clear, this returns a String<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">func bar() -&gt; String<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">{ ... }<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">// Confusing. Does this throw a String? Does it return a String? Does it do both?<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">// I personally keep reading this as &#39;this can throw a String&#39;<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">func baz() throws -&gt; String<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">// Equivalent code in Java (not a model, just for clarification of why the above is confusing)<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">String baz() throws StringFormatException</pre></div><div class="m_-5171550767766731285gmail_msg">I therefore suggest either tweaking the syntax around, or moving, the `throws` keyword to avoid this confusion.</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">Some ideas I&#39;ve had:</div><div class="m_-5171550767766731285gmail_msg"><pre style="color:inherit;margin-top:15px;margin-bottom:15px;font-family:Menlo,Consolas,&#39;Liberation Mono&#39;,Courier,monospace;font-size:10pt;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:4px 8px;word-break:normal;word-wrap:normal" class="m_-5171550767766731285gmail_msg">// Add a comma to separate them<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">func baz() throws, -&gt; String<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">// Move `throws` to the end<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">func baz() -&gt; String throws<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">// Change it to a prefix modifier (like `mutating`)<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">throwing func baz() -&gt; String<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></pre></div><div class="m_-5171550767766731285gmail_msg">I&#39;m still not sold on any of the above syntaxes, but I would love to hear your feedback.</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg">This would affect existing code, but it would be a fairly small change that would result in very large readability improvements, especially for newcomers, and <i class="m_-5171550767766731285gmail_msg">especially</i> for those coming for a language such as Java.</div><div class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><div class="m_-5171550767766731285gmail_msg"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word" class="m_-5171550767766731285gmail_msg">-thislooksfun (tlf)</div><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></div></div>______________________________<wbr>_________________<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg">swift-evolution mailing list<br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><a href="mailto:swift-evolution@swift.org" class="m_-5171550767766731285gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="m_-5171550767766731285gmail_msg" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"><br class="m_-5171550767766731285gmail_msg"></blockquote></div></div>
</div></blockquote><blockquote type="cite" class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg"><span class="m_-5171550767766731285gmail_msg">______________________________<wbr>_________________</span><br class="m_-5171550767766731285gmail_msg"><span class="m_-5171550767766731285gmail_msg">swift-evolution mailing list</span><br class="m_-5171550767766731285gmail_msg"><span class="m_-5171550767766731285gmail_msg"><a href="mailto:swift-evolution@swift.org" class="m_-5171550767766731285gmail_msg" target="_blank">swift-evolution@swift.org</a></span><br class="m_-5171550767766731285gmail_msg"><span class="m_-5171550767766731285gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="m_-5171550767766731285gmail_msg" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a></span><br class="m_-5171550767766731285gmail_msg"></div></blockquote></div></blockquote><blockquote type="cite" class="m_-5171550767766731285gmail_msg"><div class="m_-5171550767766731285gmail_msg"><span class="m_-5171550767766731285gmail_msg">______________________________<wbr>_________________</span><br class="m_-5171550767766731285gmail_msg"><span class="m_-5171550767766731285gmail_msg">swift-evolution mailing list</span><br class="m_-5171550767766731285gmail_msg"><span class="m_-5171550767766731285gmail_msg"><a href="mailto:swift-evolution@swift.org" class="m_-5171550767766731285gmail_msg" target="_blank">swift-evolution@swift.org</a></span><br class="m_-5171550767766731285gmail_msg"><span class="m_-5171550767766731285gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="m_-5171550767766731285gmail_msg" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a></span><br class="m_-5171550767766731285gmail_msg"></div></blockquote></div>______________________________<wbr>_________________<br class="m_-5171550767766731285gmail_msg">
swift-evolution mailing list<br class="m_-5171550767766731285gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="m_-5171550767766731285gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="m_-5171550767766731285gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="m_-5171550767766731285gmail_msg" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br class="m_-5171550767766731285gmail_msg">
</blockquote></div>
</div></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div></div>