<div dir="ltr">Actually, following from the idea that packing and unpacking variables should be delayed by default, it might make sense to use syntax like:<br><br>>>> a = *(2+2)<br>>>> b = a + 1<br><br>Instead of<br><br>>>> a = lazy 2+2 # or whatever you want the keyword to be<br>>>> b = a + 1<br><br>That syntax sort-of resembles generator expressions, however; I usually like how python favors actual words over obscure symbol combinations for readability's sake.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 17, 2017 at 10:57 AM, Abe Dillon <span dir="ltr"><<a href="mailto:abedillon@gmail.com" target="_blank">abedillon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'd like to suggest a shorter keyword: `lazy`<br><br>This isn't an endorsement. I haven't had time to digest how big this change would be.<br><br>If this is implemented, I'd also like to suggest that perhaps packing and unpacking should be delayed by default and not evaluated until the contents are used. It might save on many pesky edge cases that would evaluate your expression unnecessarily.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 17, 2017 at 10:43 AM, Joseph Hackman <span dir="ltr"><<a href="mailto:josephhackman@gmail.com" target="_blank">josephhackman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Agreed. I think this may require some TLC to get right, but posting here for feedback on the idea overall seemed like a good start. As far as I know, the basic list and dict do not inspect what they contain. I.e.<br>
<br>
d = {}<br>
d['a']= delayed: stuff()<br>
b=d['a']<br>
<br>
b would end up as still the thunk, and stuff wouldn't be executed until either d['a'] or b actually is read from.<br>
<span class="m_5841430610666752140HOEnZb"><font color="#888888"><br>
-Joseph<br>
</font></span><div class="m_5841430610666752140HOEnZb"><div class="m_5841430610666752140h5"><br>
> On Feb 17, 2017, at 11:34 AM, Chris Angelico <<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>> wrote:<br>
><br>
>> On Sat, Feb 18, 2017 at 3:29 AM, Joseph Hackman <<a href="mailto:josephhackman@gmail.com" target="_blank">josephhackman@gmail.com</a>> wrote:<br>
>> ChrisA: I am not sure about collections. I think it may be fine to not special case it: if the act of putting it in the collection reads anything, then it is evaluated, and if it doesn't it isn't. The ideal design goal for this would be that all existing code continues to function as if the change wasn't made at all, except that the value is evaluated at a different time.<br>
>><br>
><br>
> Yeah, I'm just worried that it'll become useless without that. For<br>
> instance, passing arguments to a function that uses *a,**kw is going<br>
> to package your thunk into a collection, and that's how (eg) the<br>
> logging module will process it.<br>
><br>
> It's not going to be easy to have a simple AND useful definition of<br>
> "this collapses the waveform, that keeps it in a quantum state", but<br>
> sorting that out is fairly key to the proposal.<br>
><br>
> ChrisA<br>
> ______________________________<wbr>_________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>