<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 style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Sorry for the resend! Some of my previous e-mail was left out for some reason. Here it is again, as it should have been:</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><blockquote type="cite" class="">On Aug 18, 2016, at 12:43 AM, Sikhapol Saijit via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></blockquote><div class=""><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div class="">1. Is it intentional that&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">try</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">?</span>&nbsp;can be used with a "non-method-call" and return an optional of the type that follows?</div></div></blockquote><div class=""><br class=""></div><div class="">a. I’m not sure what you mean by “non-method-call”, since the thing you called in your example *was* a function that was marked with “throws”. Using try? on a non-throwing function or method does indeed produce a warning.</div><div class=""><br class=""></div><div class="">b. I’m not an Apple employee or a member of the development team, but I think it probably is intentional. There are two levels of optionality going on here; one, the possibility that the throwing method could have failed, and the other, that the optional result may or may not contain a value. Either of those two things being nil could mean quite different things, so the double-optional makes sense.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">2. Should we design&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">try</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">?</span>&nbsp;to have higher precedence than&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">as</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">?&nbsp;</span>or any operators at all?</div><div class="">My intuition tells me that&nbsp;</div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;a =&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">try</span><span class="" style="font-variant-ligatures: no-common-ligatures;">? couldFailButWillNot()&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">as</span><span class="" style="font-variant-ligatures: no-common-ligatures;">?&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span></div></div><div class="">should be equivalent to</div><div class=""><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">let</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">&nbsp;a = (</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">try</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">? couldFailButWillNot())&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">as</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;">?&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span>&nbsp;</div></div></blockquote></div><br class=""><div class="">This is more debatable whether it *should* be the case, but it’s worth pointing out that try/try?/try! work on the entire rest of the line, which means you can include more throwing calls and not have to put an ! each time:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;foo()&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">throws</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;-&gt;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;{&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;bar()&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">throws</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;-&gt;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;{&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">if</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;i =&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">try</span><span class="" style="font-variant-ligatures: no-common-ligatures;">?&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(49, 89, 93);">foo</span><span class="" style="font-variant-ligatures: no-common-ligatures;">() +&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(49, 89, 93);">bar</span><span class="" style="font-variant-ligatures: no-common-ligatures;">() {&nbsp;</span><span class="" style="color: rgb(0, 132, 0);">// not try foo() + try bar()</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">(</span><span class="" style="font-variant-ligatures: no-common-ligatures;">"i is&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">\</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">i</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)"</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">)</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><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;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-family: Helvetica; font-size: 12px;">Or this:</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-family: Helvetica; font-size: 12px;"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><div class="" style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;foo()&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">throws</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;-&gt;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;{&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;}</span></div><div class="" style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;bar(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">_</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;i:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">throws</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;-&gt;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;{&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;i +&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;}</span></div><div class="" style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; min-height: 13px;"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></div><div class="" style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">if</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">&nbsp;i =&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">try</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">?&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(49, 89, 93);">bar</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(49, 89, 93);">foo</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">()) {&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">// not bar(try foo())</span></div><div class="" style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">(</span><span class="" style="font-variant-ligatures: no-common-ligatures;">"i is&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">\</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">i</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)"</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">)</span></div><div class="" style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;">So multiple throwing statements can be used on a single line without having to throw “try” all over the place. Now, whether that’s worth the admittedly confusing behavior you noted above is probably a decent topic for debate.</span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;">Charles</span></div></div></div></body></html>