@rauschma I wouldn't argue about scope of a `syntactic sugar` definition. However, an async function and generator can be transformed into `Promise` and `Iterator` implementation. Also, I agree that it's not simple, it's a good exercise to understand how generators and async functions work.
Conversation
Notices
-
Embed this notice
Sergey on FunctionalScript (functionalscript@techhub.social)'s status on Saturday, 20-Jul-2024 04:01:00 JST Sergey on FunctionalScript -
Embed this notice
Axel Rauschmayer (rauschma@fosstodon.org)'s status on Saturday, 20-Jul-2024 04:01:01 JST Axel Rauschmayer The term “syntactic sugar” is tricky. Common definition: shorter syntax with a simple transformation to a longer version. Think syntax-aware search-and-replace or macros.
Examples:
a += b // sugar
a = a + b // long{prop} // sugar
{prop: prop} // long(x) => x + x // sugar
(x) => { return x } // longWith this definition, async/await is not syntactic sugar for Promises: An async function is executed similarly to a generator (pausing, resuming, …). So no simple transformation from .then().
-
Embed this notice