4 ms·
Concur. Although perhaps the situation in Python could have been mitigated somewhat if a protocol was defined early that implementations could have adopted? Co
by timClicks 8y ago
Concur.
Although perhaps the situation in Python could have been mitigated somewhat if a protocol was defined early that implementations could have adopted? Context managers, iterators and decorators all work nicely together, even across language boundaries via the extensions API.
- sametmax 8y ago> Although perhaps the situation in Python could have been mitigated somewhat if a protocol was defined early that implementations could have adopted? Yes. That's one thing the rust community has to get right. async/await was supposed to be that, but it's only a protocol to define what blocks/doesn't and when you allow context switching. An event loop also has the notion of scheduling, getting a reference to what is scheduled, request the result or error on said scheduled thing, or cancel it. And even loop must bridge different implementations of concurrency (e.g: asyncio.run_in_executor). An event loop also has a life cycle, which includes at the very least a setup and a tear down. An event loop must integrates in an environment, like what do you do when you have several loops, or if you run one loop per threads ? So you need to define a general behavior for all that. Then let anyone write the implementation the way they want.
- steveklabnik 8y agoThat’s all of this: https://doc.rust-lang.org/nightly/core/task/ https://doc.rust-lang.org/nightly/core/task/
- sametmax 8y agoThat's an API. Like asyncio in Python is an API. If you make the event loop swapable without making this API mandatory however, it's never going to be a protocol.
- steveklabnik 8y agoThe api is mandatory; it’s how async/await works.
- sametmax 8y agoSo everybody has to implement a task for any alternative event loop and accept tasks from other implementation ?