3 ms·
This appears to redefine the concept of function colors to something different and not particularly problematic. The issue that the function color concept illu
by jmull 5y ago
This appears to redefine the concept of function colors to something different and not particularly problematic.
The issue that the function color concept illustrates is how subtle function incomposibility can seem perfectly workable for a while, but sometimes leads you to a deep dead end that takes a lot of reworking of otherwise good code to resolve.
The key limitation is that “red” functions can only be called from other “red” functions. So that if you’ve developed a bunch of code composed of “blue” functions, possibly with deep, complex call chains, and then find you need to call a “red” function at a low level, you suddenly find yourself in a dead end with no good way forward.
This article seems to drop that key point from function colors. (I say seems because it only speaks of its own definition indirectly. Maybe it’s in the deleted post mentioned at the start?)
I think that makes this whole article pretty much pointless.
- ghoward 5y agoAuthor 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.
- randyrand 5y agoTotally agree. The author is redefining color to mean function signature. If color meant function signature, why define color?