<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 19, 2015 at 9:21 AM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div><div><div><div><div><div><div><div>I forgot to think about the scope of the uptalk operator (i.e. what is skipped when it finds a None). There are some clear cases (the actual implementation should avoid double evaluation of the tested expression, of course):<br><br></div>Â a.b?.c.d[x, y](p, q) === None if a.b is None else a.b.c.d[x, y](p, q)<br></div>Â a.b?[x, y].c.d(p, q) === None if a.b is None else a.b[x, y].c.d(p, q)<br></div>Â a.b?(p, q).c.d[x, y] === None if a.b is None else a.b(p, q).c.d[x, y]<br><br></div></div></div></div></div></div></div></blockquote><div><font color="#0000ff">This makes sense to me.</font></div><div>Â </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div><div><div><div><div></div>But what about its effect on other operators in the same expression? I think this is reasonable:<br><br></div>Â a?.b + c.d === None if a is None else a.b + c.d<br></div></div></div></div></div></blockquote><div><br></div><div><font color="#0000ff">This is a bit weird to me. Essentially ?. takes precedence over a following +. But would you also expect it to take precedence over a preceding one as well? That's inconsistent.</font></div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff">c.d + a?.b === None if a is None else c.d + a.b</font></div><div><font color="#0000ff">or</font></div><div><font color="#0000ff">c.d + a?.b === c.d + None if a is None else c.d + a.b</font></div><div><br></div><div><font color="#0000ff">I think that ?. ?[] and ?() should affect other operators at the same precedence level only, i.e., Â each other and . [] and (). This seems the most logical to me. And I just looked up the C# documentation on MSDN and it does the same thing:Â <a href="https://msdn.microsoft.com/en-us/library/dn986595.aspx">https://msdn.microsoft.com/en-us/library/dn986595.aspx</a></font></div><div><font color="#0000ff"><br></font></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div><div><div><br></div></div></div>It also shouldn't escape out of comma-separated lists, argument lists, etc.:<br><br></div>Â (a?.b, x) === ((None if a is None else a.b), x)<br></div>Â f(a?.b) === f((None if a is None else a.b))<br></blockquote></div><div class="gmail_extra"><font color="#0000ff"><br></font></div><font color="#0000ff">Agree. It also should not escape grouping parenthesis even though that might not be useful. It would be very weird if a parenthesized expression did something other than evaluate the expression inside it, period.</font></div><div class="gmail_extra"><font color="#0000ff"><br></font></div><div class="gmail_extra"><font color="#0000ff">(a?.b).c === None.c if a is None else (a.b).c === temp = a?.b; temp.c</font></div><div class="gmail_extra"><span style="color:rgb(0,0,255)">(x or a?.b).c === (x or (None if a is none else a.b)).c</span></div><div class="gmail_extra"><span style="color:rgb(0,0,255)"><br></span></div><div class="gmail_extra"><span style="color:rgb(0,0,255)">Yes, None.c is going to raise an exception. That's better than just getting None IMHO.</span></div><div class="gmail_extra"><span style="color:rgb(0,0,255)"><br></span></div><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="arial, helvetica, sans-serif">--- Bruce<br></font><div><div><font face="arial, helvetica, sans-serif">Check out my new puzzle book:Â <a href="http://J.mp/ingToConclusions" target="_blank">http://J.mp/ingToConclusions</a></font><br></div></div><div><font face="arial, helvetica, sans-serif">Get it free here:Â <a href="http://J.mp/ingToConclusionsFree" target="_blank">http://J.mp/ingToConclusionsFree</a>Â (available on iOS)</font></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div></div>