3 ms·
People mean one of two different things when they talk about “function colors”. Let’s take the example of JS. Does JS have function colors? In one sense, yes,
by zarzavat 5y ago
People mean one of two different things when they talk about “function colors”.
Let’s take the example of JS. Does JS have function colors?
In one sense, yes, there are async functions and sync functions and you can only call an async function from an async function. So under a certain definition, JS functions are colorful.
But wait... a JS async function is just a normal function that returns a Promise object. So under another definition, JS functions are colorless. Perhaps someone might not like how Promises work in JS, but this has nothing to do with what color the functions are.
There are some languages that do break this and implement async functions as a completely different entity to normal functions. I believe this kind of function colors is lazy and bad language design and these async implementations tend to feel like they don’t belong with the rest of the language and were duct taped on.
- Dylan16807 5y agoThe async keyword strongly changes the internals of a function to let it use "await". Even if you do it manually, it's a very particular and restricted style that infects your caller. That's a color.