by spacebuffer on 9/1/23, 10:42 PM with 47 comments
by flohofwoe on 9/2/23, 10:55 AM
For instance look at the JS output of async/await Typescript when a really old JS version is used that didn't support async/await yet.
It's switch-case all the way down:
https://www.typescriptlang.org/play?target=1#code/FAMwrgdgxg...
by l5870uoo9y on 9/2/23, 8:35 AM
> Generators are a special type of function that can return multiple pieces of data during its execution. Traditional functions can return multiple data by using structures like Arrays and Objects, but Generators return data whenever the caller asks for it, and they pause execution until they are asked to continue to generate and return more data.
Applications of generators? I have only used Redux-Saga[1]. Can't even think of other libraries that use them, but would be interested in learning.
by rzimmerman on 9/2/23, 2:02 AM
It included try/catch support and fancy stuff, like loops. The source may be interesting for anyone interested in compilers: https://github.com/rzimmerman/kal/blob/master/source/generat...
The Kal compiler is written in Kal, but it's supposed to be easy to read. Surprisingly the browser demo still works: http://rzimmerman.github.io/kal/demo.html
by winrid on 9/2/23, 7:23 AM
by trashburger on 9/2/23, 7:19 AM
by quectophoton on 9/2/23, 8:24 AM
I haven't used that much JS recently, but my guess is that "for await of" will make generators more widely known and used.
by endorphine on 9/2/23, 8:24 AM
by h1fra on 9/2/23, 11:29 AM
by _akash_h on 9/5/23, 7:17 AM
Thank you to everyone who read my article! Absolutely love some of the discussions going on here. My goal with the article was to peel away one layer of this abstraction and encourage curiosity in engineers who usually don't think about lower level stuff.
by plopz on 9/2/23, 2:27 PM