|
|
|
|
|
by DixieDev
1530 days ago
|
|
This article was my first exposure to async in Zig, and I find it rather at odds with the "No hidden control flow" selling point of the language. fn foo() void {
bar();
std.log.info("bar is finished");
baz();
std.log.info("baz is finished");
}
I cannot just look at this function and know what it's doing and how to use it. If bar()'s implementation contains a suspend or await keyword then this won't compile when called from main() unless its call is prefixed with async, and even if I do so then I also have to make sure I resume foo enough times for bar (or baz) to finish too. Am I missing some key detail here? It seems out of place compared to many other language features. |
|
Specifically, examine this:
It looks dead simple, but it's a pain in the butt to use because it's actually async, and you can know neither that nor how to get this function to actually finish without looking inside of bar().