wt., 21 cze 2022 o 05:20 Steven D'Aprano <st...@pearwood.info> napisaƂ(a):

> The point is, Rob thought (and possibly still does, for all I know) that
> lazy evaluation is completely orthogonal to late-bound defaults. The PEP
> makes that claim too, even though it is not correct. With a couple of
> tweaks that we have to do anyway, and perhaps a change of syntax (and
> maybe not even that!) we can get late-bound defaults *almost* for free
> if we had lazy evaluation.

That depends of lazy evaluation spec, if lazy expression would ever
become a thing in python, it may be defined to have syntax like `lazy
<expr>` which would be rough equivalent off `LazyObject(lambda:
<expr>)` that would evaluate that lambda at most once, plus some
interpreter tweaks to make LazyObject transparent to python code.

so for this code (`??` replaced with different combination of
early/late and not lazy/lazy)

```
x = []

def f(x, y, z ?? len(x)):
  x.append(y)
  print(z, end = ' ')

x.append(0)
f([1, 2, 3], 4)
x.append(0)
f([1, 2, 3, 4], 4)
```

I expect that
for `??` = `=` I get `0 0 `
for `??` = `=>` I get `3 4 `
for `??` = `= lazy` I get `1 1`
for '??' = `=> lazy` I get `4 5 `

That would be completely orthogonal.
_______________________________________________
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/GZ2OCWGI67FTZGTCNHHYAXB7Y54LBTPY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to