2 ms·
Author here. The definition that I use is the bolded one near the beginning: > some functions cannot be used without special work.
by ghoward 5y ago
Author here.
The definition that I use is the bolded one near the beginning:
> some functions cannot be used without special work.
- jmull 5y agoThe article would be much better if you dropped mentioning function colors at all then, since your definition really has little to do with the original concept. As-is, bringing it up just muddies your argument. Critically, function colors are an issue of the language design and here you’re finding limitations in the language implementation.
- ghoward 5y ago> The article would be much better if you dropped mentioning function colors at all then, since your definition really has little to do with the original concept. I heavily disagree, but near the end of the post, I also show that Zig does fit the original definition: > 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.
- jmull 5y agoThat’s just changing the definition of function colors. In the original definition the fundamental distinction between functions of different colors is which colors can call which other colors. In zig async functions can call async and non-async functions, and non-async functions can call async and non-async functions. Thus, no “color” distinction. It’s just pointless to ascribe the existing terminology of function colors while fundamentally changing the concept to something else. You end up making no point at all.
- ghoward 5y agoThen you and I disagree about the definition of function colors. But Zig's language reference is clear: when needed, blue functions are turned into red functions transparently at compile time. What that does is make it seem as though there are no colors. That's why the dichotomy can be exposed at runtime: the compiler can't intervene and turn blue functions into red functions. No matter how much you say that changes the definition, it still means that blue functions cannot call red functions. The fact that functions are turned into red functions does not magically make the colors disappear; it just hides their existence until it cannot be hidden anymore.