
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. The reason this could appeal to me is that it wouldn't be limited to function signatures, nor even necessarily most useful there. Instead, a deferred object would be a completely general thing that could be bound anywhere any object can. Such a capability would allow passing around potential computational "code blocks", but only perform the work if or when a value is required.