Comment by zarzavat

Comment by zarzavat 13 hours ago

2 replies

In that case JS is not colored either because an async function is simply a normal function that returns a Promise.

As far as I understand, coloring refers to async and sync functions having the same calling syntax and interface, I.e.

    b = readFileAsync(p)
    b = readFileSync(p)
share the same calling syntax. Whereas

    b = await readFileAsync(p)
    readFileAsync(p).then(b => ...)
    
    b = readFileSync(b)
are different.

If you have to call async functions with a different syntax or interface, then it's colored.

flohofwoe 4 hours ago

> In that case JS is not colored either because an async function is simply a normal function that returns a Promise.

Exactly, IMHO at least, JS doesn't suffer from the coloring problem because you can call async functions from sync functions (because the JS Promise machinery allows to fall back to completion callbacks instead of using await). It's the 'virality' of await which causes the coloring problem, but in JS you can freely mix await and completion callbacks for async operations).

  • zarzavat 3 hours ago

    await isn't viral per se, it's a purely local transformation. The virality is from CPS/callbacks and Promise.