4 ms·
I 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 differen
by 59nadir 3y ago
I 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).