4 ms·
Multi-colored? Google doesn't spit out anything meaningful and ChatGPT claims that Zig didn't exist in Sept 2021...
by valenterry 3y ago
Multi-colored? Google doesn't spit out anything meaningful and ChatGPT claims that Zig didn't exist in Sept 2021...
- 59nadir 3y agoI think in popular parlance the terminology comes from the "What color is your function?" article[0]. The idea is that "normal" and async functions are different colors and they don't mix. When you call an async function from a normal one you make the normal one async, i.e. if it had no color it now takes on the color of the async one, etc. Zig has a system where calling an async function is actually doable while still leaving the calling function non-async. 0 - https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
- valenterry 3y agoOh yeah, I know about that. But that is commonly called "colored functions" not "multi colored functions" no? So I thought there was a difference.
- littlestymaar 3y agoZig aims to solve this “problem” by having functions that can be either async or not.
- wtetzner 3y agoRight, colored functions are e.g. async or not async. In Zig, you can write a single function that works as both, which I assume is what multicolored means here.
- valenterry 3y agoThat doesn't seem to make any sense to me - it should be then called uncolored functions no? Because they all look the same. But maybe that's what they ment to say.
- kps 3y agoThey're generic over ‘color’ at compile time; the compiler generates code for normal and/or async contexts as necessary.
- valenterry 3y agoRight - so to the developer they all look the same, which means they are uncolored. If they are colored it means they look different (e.g. async vs sync).
- a1369209993 3y agoThey're (presumably) refering to "colorblind" functions. (Note that "blind" is apt here: the color isn't visible, but functions still have color and will break in subtle ways if you try to use them as if they don't.[0]) Zig's approach is probably a improvement over bare async/await, but pre-javascript languages already had more of a improvement in the form of not having async/await. Implementing async/await at all makes the language worse unless there's a (preferably provably) universally-applicable way for functions to be (explicitly) generic about whether they're async or not. 0: https://gavinhoward.com/2022/04/i-believe-zig-has-function-colors/ https://gavinhoward.com/2022/04/i-believe-zig-has-function-c...
- hansvm 3y agoChatGPT isn't great for spitting out accurate facts, especially if you just ask once, especially if you don't add additional details and otherwise engineer the prompt, especially if you're asking questions involving digits and numerals, and you especially if small details matter. Zig was definitely far enough along to have multi-colored functions over a year prior to that.