
wt., 21 cze 2022 o 05:20 Steven D'Aprano <steve@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.