On Wed, Jun 22, 2022 at 02:30:14PM -0400, David Mertz, Ph.D. wrote:
But basically, think about `x = (later expensive1() + later expensive2())
later expensive3()`. How can we make `x` itself be a zero argument lambda? [... see below ...]
x = lambda: (expensive1() + expensive2()) / expensive3()
What am I missing?
I don't understand what you meant by saying that zero-argument lambdas are "isolated". It sounds like a way that you happen to think about lambdas, and not an objective property of lambdas.
This proposal is like lambda on the definition end, but on the invocation end the call happens implicitly. In effect you have to explicitly mark everywhere that you *don't* want it to be called instead of everywhere that you *do* want it to be called. It isn't clear to me that that's better, much less enough better to justify changing the semantics of what I suppose is the single most common operation in Python ("getting a value").
On Wed, Jun 22, 2022 at 2:53 PM Martin Di Paola email@example.com wrote:
# Using zero-argument nested lambdas x = lambda: ((lambda: expensive1())() + (lambda: expensive2())()) / (lambda: expensive3())()
Why not just expensive1() instead of (lambda: expensive1())()?