3 ms·
Instead of f2(g(h2())) you'd write something like f2(async { g(h2().await) }).await if f2 takes a future, or f2(g(h2().await)).await if it takes a v
by majewsky 6y ago
Instead of
f2(g(h2()))
you'd write something like
f2(async { g(h2().await) }).await
if f2 takes a future, or
f2(g(h2().await)).await
if it takes a value. (The latter is more common.) The equivalent in JS would be
await f2(g(await h2()))
- pansa2 6y agoThe example uses `g(h2)`, not `g(h2())` - `g` takes the function `h2` as an argument, and the call(s) to `h2` are made from within `g` itself. If calling `h2` requires an `await` if and only if `h2` is async, then the function `g` can’t be used for both the synchronous and async cases. AFAIK this is the main objection to having two function colours.
- gpderetta 6y agoexactly this. Unless the language allows abstracting over the async/non-async calls.