3 ms·
I disagree, because you're paying for boxing on return + dynamic dispatch when it's perfectly safe/sound to have a stackful coroutine that only allocates when t
by duped 4y ago
I disagree, because you're paying for boxing on return + dynamic dispatch when it's perfectly safe/sound to have a stackful coroutine that only allocates when the stack needs to grow and doesn't require dynamic dispatch. So you don't pay for heap allocated futures if they aren't necessary, and you pay less when they are.
So you're actually paying a higher price than if the compiler could support stackful generators for recursive futures. In fact async just gets a lot easier to write and use if generators could be stackful, at least imho. Generators don't have the syntax nice-ness of async/await, but they're also more explicit which feels more in with the rest of Rust, where syntax sugar like async/.await() is the exception and not the norm.
- JoshTriplett 4y agoFair enough, if we could create generators and futures that switch stacks that might work.
- deleted 4y ago[deleted]
- veber-alex 4y agostackful coroutines break FFI
- duped 4y agoHow so? You can swap stacks in posix just fine modulo some setjmp/longjmp shenanigans. But exceptions aren't sound across FFI either.