Comment by rowanG077
Comment by rowanG077 19 hours ago
But that can already be done using async await. If you write an async function in Rust for example you are free to call it with any async runtime you want.
Comment by rowanG077 19 hours ago
But that can already be done using async await. If you write an async function in Rust for example you are free to call it with any async runtime you want.
yes, you can:
runtime.block_on(async { })
https://play.rust-lang.org/?version=stable&mode=debug&editio...Let me rephrase, you can't call it like any other function.
In Zig, a function that does IO can be called the same way whether or not it performs async operations or not. And if those async operations don't need concurrency (which Zig expresses separately to asynchronicity), then they'll run equally well on a sync Io runtime.
> In Zig, a function that does IO can be called the same way whether or not it performs async operations or not.
no, you can't, you need to pass a IO parameter
Here's a problem with that:
Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
https://play.rust-lang.org/?version=stable&mode=debug&editio...
But you can't call it from synchronous rust. Zig is moving toward all sync code also using the Io interface.