An interesting idea, essentially Trio restructures concurrent code to more closely resemble parallel code, which innately has the property that the concurrency is not observable, ie. the black box property. It's a little more general than strict parallel code though because task spawning is reified as a first class value via which the program can spawn new tasks.
I'm not sure it's totally novel though. For instance, C# has AsParallel() extensions which let you run collection operations in parallel (similar functions in Haskell too). It has the same black box behaviour described by the article, and there's an equivalence between direct control flow in code and indirect control flow reified as a data structure, ie. Haskell's case that lazy evaluation and lists are the only control flow construct you need.
Still, it's an interesting imperative incarnation of the idea!
Re:Waiting in Asyncio
by nerdwaller on Saturday May 23, 2020 @08:50AM
(#23282499)
Fair enough, the ensure_future() vs create_task() has confused me more than once. It would have been nice if there was a different namespace for the lower level API.
Even so, the docs aren’t even clear on when which of the two is appropriate:
https://docs.python.org/3/library/asyncio-task.html#asyncio.....
https://docs.python.org/3/library/asyncio-future.html#asynci....
For a theoretical take see
https://vorpus.org/blog/notes-on-structured-concurrency-or-g...
To be precise, to wait for a task its actually just await. Theres no ensure_future etc. Trio doesn't have the concept of futures or promises at all, and await f() is treated as a single piece of syntax, so in practice it doesn't have "awaitables" either.