<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div>"Uptalk" is an interesting speech pattern where every sentence sounds like a question. Google it, there's some interesting research.<br><br></div>The "null pattern" is terrible. Uptalk should not be considered a unary operator that returns a magical value. It's a modifier on other operators (somewhat similar to the way "+=" and friends are formed).<br><br></div><div>In case someone missed it, uptalk should test for None, not for a falsey value.<br></div><div><br></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>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><br></div>OTOH I don't think it should affect shortcut boolean operators (and, or):<br><br></div>  a?.b or x === (None if a is None else a.b) or x<br><br></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><br></div>Should it escape from plain parentheses? Which of these is better?<br><br></div>  (a?.b) + c === (None if a is None else a.b) + c    # Fails unless c overloads None+c<br clear="all"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div class="gmail_extra">  (a?.b) + c === None if a is None else (a.b) + c    # Could be surprising if ? is deeply nested<br><br></div><div class="gmail_extra">Here are some more edge cases / hypergeneralizations:<br><br></div><div class="gmail_extra">  {k1?: v1, k2: v2} === {k2: v2} if k1 is None else {k1: v1, k2: v2}   # ?: skips if key is None<br></div><div class="gmail_extra">  # But what to do to skip None values?<br><br></div><div class="gmail_extra">Could we give ?= a meaning in assignment, e.g. x ?= y could mean:<br><br></div><div class="gmail_extra">  if y is not None:<br></div><div class="gmail_extra">   Â Â  x = y<br><br></div><div class="gmail_extra">More fun: x ?+= y could mean:<br><br></div><div class="gmail_extra">  if x is None:<br></div><div class="gmail_extra">      x = y<br></div><div class="gmail_extra">  elif y is not None:<br></div><div class="gmail_extra">      y += y<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">You see where this is going. Downhill fast. :-)<br></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>