by hsn915 · 4y ago · 0 comments
Now, I don't know much about Zig's async story to comment on this post, but this is exactly my problem with Zig's async.
Zig's top self-promoted feature is language simplicity. "You don't have to debug your knowledge about the language". But with async, that's exactly what I would have to do. I tried to read the articles about Zig's async several times but the idea never clicked in my head.
Maybe I'm just dumb.
Besides where a sibling comment says I mentioned it, I also mentioned it near the end:
> Third, async is, in fact, viral. The language reference says,
>> Zig infers that a function is async when it observes that the function contains a suspension point. Async functions can be called the same as normal functions. A function call of an async function is a suspend point.
> (Emphasis added.)
> In other words, if you call an async function, your function gets a suspend point, which means that your function becomes async.
> In fact, if you look at Bob Nystrom’s point 3, “You can only call a red function from within another red function,” this means that Zig fits point 3!
> What Zig does differently than Bob Nystrom’s “hypothetical” language is that if it sees you call a red function from a blue function, it shrugs its shoulders, makes the blue function red, and does not tell you. This gives the appearance of being able to call red functions from blue functions while still only allowing red functions to call red functions.
So I argue that Zig actually does fit point 3.
That is what I mean by viral: if a function low in the call chain is turned `async`, every function above it is too.
> This difference of opinion is probably what caused most of the conflict I alluded to earlier, so I thought that I would lay it out, then make my case for it, along with the case that Zig has function colors according to my definition.
You're right, but it's not like they don't address that.