4 ms·
You omit the most important point about the definition of function colors. Point 3. You can only call red functions from other red functions. That's the only pr
by hsn915 5y ago
You omit the most important point about the definition of function colors. Point 3. You can only call red functions from other red functions. That's the only problem with `async` functions.
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.
- staticassertion 5y ago> My definition, however, does not fit point 3. This is on purpose; from the first time that I read Bob Nystrom’s post, I never believed that point 3 was a prerequisite for function colors. > 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.
- ghoward 5y agoAuthor here. 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.
- hsn915 5y agoThat's interesting. So this means that the only thing Zig does is auto-insert the 'async' qualifiers in front of functions instead of requiring you to insert them?
- gavinhoward 5y agoAs far as I understand it, yes, as well as, insert an `await` right after, turning the enclosing function itself `async`, which means that anything that calls the enclosing function (the caller) would also need to have `async` and `await` inserted, and the process would keep going. That is what I mean by viral: if a function low in the call chain is turned `async`, every function above it is too.