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. >
_______________________________________________ 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/M77Z4AL2W435YUDXHH7TBHDEVF5RVLKK/ Code of Conduct: http://python.org/psf/codeofconduct/