On Sun, Oct 24, 2021 at 5:53 PM Steven D'Aprano <st...@pearwood.info> wrote: > > On Sun, Oct 24, 2021 at 02:09:59PM +1100, Chris Angelico wrote: > > > The biggest problem with thunks is knowing when to trigger evaluation. > > I think Algol solved that problem by having thunks a purely internal > mechanism, not a first-class value that users could store or pass > around.
If you can't pass them around, then how are they different from what's proposed here? They are simply expressions that get evaluated a bit later. You potentially win on performance if it's expensive, but you lose on debuggability when errors happen further down and less consistently, and otherwise, it's exactly the same thing. > If we had thunks, that would give us late binding for free: > > def bisect(a, x, lo=0, hi=thunk len(a), *, key=None) > > Aaaand we're done. So thunks would make this PEP obsolete. > > But if thunks are implausible, too hard, or would have too high a cost, > then this PEP remains less ambitious and therefore easier. > Where else would you use thunks? I think it's exactly as ambitious, if indeed they can't be stored or passed around. ChrisA _______________________________________________ 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/UUCMBELGELSD73ONYH54FCGI6JCCSXBA/ Code of Conduct: http://python.org/psf/codeofconduct/