
On Sun, Oct 24, 2021 at 2:21 PM David Mertz, Ph.D. <david.mertz@gmail.com> wrote:
On Sat, Oct 23, 2021, 10:58 PM Steven D'Aprano
... On the other hand, if this could express a much more general deferred computation, I'd be really enthusiastic (subject to syntax and behavioral details).
However, I recognize that a new general "dynamically scoped lambda" would indeed have a lot of edge cases.
Dynamic scoping is not the same as deferred computation.
Of course not generally. But a dynamic deferred could cover this specific desire of the proposal.
So stawman proposal:
def fun(seq, low=0, high=defer: len(seq)): assert low < high # other stuff...
Where the implication here is that the "defer expression" creates a dynamic scope.
At what point is this defer-expression to be evaluated? For instance: def f(x=defer: a + b): a, b = 3, 5 return x Would this return 8, or a defer-expression? If 8, then the scope isn't truly dynamic, since there's no way to keep it deferred until it moves to another scope. If not 8, then I'm not sure how you'd define the scope or what triggers its evaluation. ChrisA