On Fri, Mar 3, 2017 at 10:10 AM, Abe Dillon <abedil...@gmail.com> wrote:
> I really think the whole "lazy" idea is misguided. If it's possible for the
> interpreter to determine automatically when it needs to force evaluation of
> a lazy expression or statement, then why not make *all* expressions and
> statements lazy by default? I think it's pretty clear when to force
> evaluation: 1) when the result is used in a control flow
> statement/expression 2) when the result is output (file, network, or other
> I/O)  and 3) evaluate all pending lazy code before releasing the GIL. At
> that point, why not make lazy evaluation an implicit feature of the
> language, like the garbage collector.

4) When the evaluation will have side effects.

Making everything lazy is fine when you can guarantee that there's no
visible effect (modulo performance) of evaluating things in a
different order, or not evaluating some of them at all. In Python,
that can't be guaranteed, so universal laziness is way too dangerous.
Think of all the problems people have with getting their heads around
multithreading, and consider that this is basically going to take your
code and turn it into a bunch of threads, and join on those threads
only when there's a reason to. Debugging becomes highly
non-deterministic, because adding a quick little 'print' call to see
what's going on might force evaluation a little sooner, which means X
happens before Y, but without that print, Y happens before X... aeons
of fun.

No, if laziness is added to Python, it *must* be under programmer control.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to