2 ms·
I think this (allowing some form of default for backwards compatibility) is a underrated point. The common modern example being async functions, I would say it
by ledauphin 6y ago
I think this (allowing some form of default for backwards compatibility) is a underrated point.
The common modern example being async functions, I would say it's actually quite surprising that JavaScript can't seem to provide the sane default behavior of "block this non-async function until the async function it calls returns a value".
The reason it can't is simply that it chooses not to provide a runtime with a true threading model - blocking a non-async function means literally blocking the entire runtime. But there's a possible world in which a "colored" (async) function could be used directly in a synchronous function using an escape hatch provided by the runtime, and then async functions would no longer be colored in the same way.