<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">At this point, I'm not sure whether this is an -evolution question or a -dev question. The latter would be much easier to work on at this time and could potentially be postponed to a dot release. I know that any conversation not directly related to 3.0 right now is a Bad Thing. </div><div class=""><br class=""></div><div class="">And I suspect that Steven C is probably the right person to know about wrangling precedence and existing standards.</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 5, 2016, at 12:30 AM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" class="">jtbandes@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Now you've gotten me thinking about precedence of other operators too.<div class=""><br class=""></div><div class="">Since ?? is prone to causing confusion in either direction (cf. your example and my example), it could be put in its own group whose relation to the numeric operators is intentionally undefined (thus requiring parens).</div><div class=""><br class=""></div><div class="">I don't know about other folks, but I'll certainly get confused if & and | and ^ are mixed. What if we removed their relation to each other (requiring parens when mixing them)?</div><div class=""><br class=""></div><div class=""><span id="cid:ii_156f907765852272"><proposed-precedence.png></span><br class=""></div><div class=""><br class=""></div><div class="">For comparison (ha), here's what we have today:</div><div class=""><br class=""></div><div class=""><span id="cid:ii_156f909c4fae30a2"><current-precedence.png></span><br class=""></div><div class=""><div class="gmail_extra"><br clear="all" class=""><div class=""><div data-smartmail="gmail_signature" class=""><div dir="ltr" class=""><div class="">Jacob<br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Sat, Sep 3, 2016 at 10:20 PM, Erica Sadun <span dir="ltr" class=""><<a href="mailto:erica@ericasadun.com" target="_blank" class="">erica@ericasadun.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Sep 3, 2016, at 10:15 PM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" target="_blank" class="">jtbandes@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Perhaps-conversely, what should this code do?<div class=""><br class=""></div><div class=""> let nextIndex = foundIndex ?? lastIndex + 1</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div data-smartmail="gmail_signature" class=""><div dir="ltr" class=""><div class="">Jacob<br class=""></div></div></div></div></div></div></div></blockquote><div class=""><br class=""></div></span>It's a good counter example. And there's no optional-associative option.</div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- E</div></font></span><span class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra">
<br class=""><div class="gmail_quote">On Sat, Sep 3, 2016 at 9:05 PM, Erica Sadun via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Given: `<font face="Menlo" class="">let x = Optional(3)</font>` then<blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><span style="font-family:Menlo" class="">`let y = 5 + x ?? 2` </span>will not compile</div></blockquote><div class="">but </div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><font face="Menlo" class="">`let y = 5 + (x ?? 2)` </font>will.</div></blockquote><div class=""><br class=""></div><div class="">Should <font face="Menlo" class="">NilCoalescingPrecedence</font> be raised? The current operator precedence chain is:</div><div class=""><br class=""></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><div class=""><font face="Menlo" class="">BitwiseShiftPrecedence > MultiplicationPrecedence > AdditionPrecedence > RangeFormationPrecedence > CastingPrecedence > NilCoalescingPrecedence > ComparisonPrecedence > LogicalConjunctionPrecedence > LogicalDisjunctionPrecedence > TernaryPrecedence > AssignmentPrecedence > FunctionArrowPrecedence > [nothing]</font></div></div></blockquote><div class=""><br class=""></div><div class="">It seems to me that `<font face="Menlo" class="">NilCoalescingPrecedence</font>` should probably be higher than `<font face="Menlo" class="">MultiplicationPrecedence</font>` and possibly higher `<font face="Menlo" class="">BitwiseShiftPrecedence</font>` as its job is to produce an unwrapped value that can then be operated upon.</div><div class=""><br class=""></div><div class="">I think <font face="Menlo" class="">CastingPrecedence</font> should be even higher because</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><span style="font-family:Menlo" class="">`expression as? T ?? fallback value`</span></div></blockquote><div class="">should be parsed as</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class=""><span style="font-family:Menlo" class="">`(expression as? T) ?? (fallback value)`</span></div></blockquote><div class=""><br class=""></div><div class="">I apologize profusely because I know this is beyond last minute,</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailma<wbr class="">n/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></span></div></blockquote></div><br class=""></div></div></div>
</div></blockquote></div><br class=""></body></html>