3 ms·
As a low-level primitive to be used with await, only compatible with async functions. Which, if you think about it, is not as unusual as it sounds! In JavaScr
by comex 6y ago
As a low-level primitive to be used with await, only compatible with async functions.
Which, if you think about it, is not as unusual as it sounds! In JavaScript, for instance, awaiting an object is equivalent to calling .then() on it, passing a closure which, when called, continues the function that awaited. In other words, JavaScript’s await is call/cc. It just uses .then() instead of a direct call, and has some extra complexity in the form of the ‘rejected’ callback. Other than that it’s the same thing.
Edit: Well, except for the part where you can’t call the resume function more than once (I think?). Which is apparently also the case with this Swift version.
- deleted 6y ago[deleted]