<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div><div><span style="background-color: rgba(255, 255, 255, 0);">I like "throwing" as a prefix. It's reads well and fits very nicely with "mutating".</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">Remembering where to put the keyword for is also easier if it's at the beginning, where it fits grammatically as "throwing func".</span></div></div><div><br>On 26 Dec 2016, at 19:53, Micah Hainline via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div></div><div>I'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'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'd want both styles to work even if one was preferred or the other was deprecated.&nbsp;</div><div><br></div><div><br></div><div><br>On Dec 26, 2016, at 12:41 PM, Derrick Ho via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div>I personally do not see anything wrong with its current placement.<br class="gmail_msg"><br class="gmail_msg">It may be there because it was based on an existing cocoa pattern from objective-c<br class="gmail_msg"><br class="gmail_msg">- (NSString *)bazWithError:(NSError **)error { ... }</div><div><br></div><div>Because objective c could only return one thing, using pointer-to-pointer was needed to deliver more than one.</div><div><br></div><div>When swift came along it became this...</div><div><br></div><div>func baz(error: NSErrorPointer) -&gt; String</div><div><br></div><div>The style felt old-fashioned and was replaced with throw.</div><div><br></div><div>func baz() throws -&gt; String</div><div><br></div><div><br></div><div>The evolution is consistent.&nbsp; The pattern is familiar.&nbsp; I think we should keep the placement of throw as it is.</div><div><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">On Mon, Dec 26, 2016 at 9:38 AM thislooksfun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">Hello Swifters,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I've been writing a lot more Swift code recently, and I have found that the default placement of the 'throws' 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="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">For example,</div><div class="gmail_msg"><div class="m_7524104568081187879m_-7031938144007969227bloop_markdown gmail_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,'Liberation Mono',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="gmail_msg">// This is pretty clear, this can throw an error<br><br>func foo() throws<br><br>{ ... }<br><br><br><br>// Also pretty clear, this returns a String<br><br>func bar() -&gt; String<br><br>{ ... }<br><br><br><br>// Confusing. Does this throw a String? Does it return a String? Does it do both?<br><br>// I personally keep reading this as 'this can throw a String'<br><br>func baz() throws -&gt; String<br><br><br><br>// Equivalent code in Java (not a model, just for clarification of why the above is confusing)<br><br>String baz() throws StringFormatException</pre></div><div class="gmail_msg">I therefore suggest either tweaking the syntax around, or moving, the `throws` keyword to avoid this confusion.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Some ideas I've had:</div><div class="gmail_msg"><pre style="color:inherit;margin-top:15px;margin-bottom:15px;font-family:Menlo,Consolas,'Liberation Mono',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="gmail_msg">// Add a comma to separate them<br><br>func baz() throws, -&gt; String<br><br><br><br>// Move `throws` to the end<br><br>func baz() -&gt; String throws<br><br><br><br>// Change it to a prefix modifier (like `mutating`)<br><br>throwing func baz() -&gt; String<br><br></pre></div><div class="gmail_msg">I'm still not sold on any of the above syntaxes, but I would love to hear your feedback.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_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="gmail_msg">especially</i>&nbsp;for those coming for a language such as Java.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_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="gmail_msg">-thislooksfun (tlf)</div><br><br><br><br></div><br><br><br class="gmail_msg"></div></div>_______________________________________________<br class="gmail_msg"><br><br>swift-evolution mailing list<br class="gmail_msg"><br><br><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><br><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"><br><br></blockquote></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>