<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Jul 25, 2018 at 10:41 PM Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">A bit problematic. But after (a) figuring out that your module is<br>
named "coalesce" even though I installed "coalescing" AND (b) going<br>
and separately installing wrapt, and finally (c) doing the import that<br>
you didn't mention, we still have this fundamental problem:<br></blockquote><div><br></div><div>Yeah, yeah.  I know it's alpha software I wrote two nights ago, and slightly patched 5 minutes before that post.  You fixed those concerns; I'll happily take PRs on fixing them better.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">>>> from coalesce import NullCoalesce<br>
>>> from types import SimpleNamespace<br>
>>> spam, spam.eggs, spam.eggs.bacon = SimpleNamespace(), SimpleNamespace(), 42<br>
>>> NullCoalesce(spam).eggs.bacon<br>
<NullCoalesce proxy for 42><br>
<br>
That isn't 42. That's a thing that, forever afterwards, will be a<br>
proxy. </blockquote><div><br></div><div>Yeah.  That's a thing it does.  It's less of an issue than you think since, e.g.:</div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_quote"><div><div><font face="monospace, monospace">>>> from coalesce import NullCoalesce</font></div></div></div><div class="gmail_quote"><div><div><font face="monospace, monospace">>>> from types import SimpleNamespace</font></div></div></div><div class="gmail_quote"><div><div><font face="monospace, monospace">>>> spam, spam.eggs, spam.eggs.bacon = SimpleNamespace(), SimpleNamespace(), 42</font></div></div></div><div class="gmail_quote"><div><div><font face="monospace, monospace">>>> NullCoalesce(spam).eggs.bacon + 1</font></div></div></div><div class="gmail_quote"><div><div><font face="monospace, monospace">43</font></div></div><div><font face="monospace, monospace"><div>>>> NullCoalesce(spam).eggs.bacon * 1</div><div>42</div></font></div></div></blockquote><div class="gmail_quote"><div><br></div><div>Most things you actually do with the proxy wind up getting the value back once it is used.  However, this seems to be a bug that I inherit from wrapt.ObjectProxy:</div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_quote"><div><div><font face="monospace, monospace">>>> NullCoalesce(spam).eggs.bacon + 0</font></div></div></div><div class="gmail_quote"><div><div><font face="monospace, monospace">ValueError: wrapper has not been initialized</font></div></div></div></blockquote><div class="gmail_quote"><div> </div><div>If you do an operation that combines the proxy value with "Falsey" values, it doesn't do the implicit unboxing.  Same with e.g. `proxyval + ""` for strings, unfortunately.  I'm not sure how to fix that.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">>>> spam.nil = None<br>>>> print(NullCoalesce(spam).nil.nil)<br>
None<br>
>>> print(NullCoalesce(spam).nil.nil.nil)<br>
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
AttributeError: 'NoneType' object has no attribute 'nil'<br></blockquote><div><br></div><div>Why is this wrong? This is EXACTLY the same behavior as the `?.` operator would have in the last case.  Do you not recognize the behavior you are advocating in PEP 505?</div><div><br></div><div>I recognize that the proxy value not always "auto-unboxing" is a limitation that I don't like.</div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div></div>