On Mon, 6 Dec 2021 at 11:21, Chris Angelico <ros...@gmail.com> wrote:

> The reason I consider this to be an independent proposal, and NOT a
> mechanism for late-bound defaults, is this problem:
>
> def f(lst, n=>len(lst)):
>     lst.append(1)
>     print(n)
>
> f([10, 20, 30])
>
> A late-bound default should print 3. A deferred expression should
> print 4. They're not a more general solution to the same question;
> they're a solution to a different question that has some overlap in
> what it can achieve. A None-coalescing operator would also have some
> overlap with each of the above, but it is, again, not the same thing.

As I said, no-one is being clear about what they mean by "deferred
expressions". My strawman had an explicit syntax for "undeferring" for
precisely this reason, it lets the programmer decide whether to
undefer before or after the append.

Most of the objections to deferred expressions that I've seen seem to
involve this confusion - objectors assume that evaluation happens
"magically" and then object to the fact that the place they want the
evaluation to happen doesn't match with the place they assume the
magic would occur. I see this as more of an argument that implicit
evaluation is a non-starter, and therefore deferred expressions should
be explicitly evaluated.

Paul
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/SKZKVJH4HNYQUIRZSIQS4E72CDIGN4ED/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to