[Python-ideas] Another way to avoid clumsy lambdas, while adding new functionality

Andrew Barnert abarnert at yahoo.com
Thu Mar 6 00:20:12 CET 2014


On Mar 5, 2014, at 7:35, Steven D'Aprano <steve at pearwood.info> wrote:

> So as you can see, what I've been calling a thunk is not precisely like 
> Algol thunks. One thing which is missing is the dynamic scoping: in the 
> thunk evaluation, the x comes from the caller's scope. But the delayed 
> evaluation part is quite similar, enough that I think the name may be 
> appropriate. Another name for this might be a "promise", as in the 
> promise to execute a computation later.

As I mentioned in one of the previous threads, Alice does lazy evaluation with futures and promises--the same construct it uses for concurrent scheduling, closely related to what Python has in concurrent.futures (Python merges futures and promises into a single object with two different APIs, but the idea is the same).

If `expr` evaluated to an object with the same API as a concurrent.futures.Future, that's not a terrible form of explicit evaluation. But if it's doing something like dynamic scoping, it might look pretty misleading.



More information about the Python-ideas mailing list