6 ms·
Internals of the async/await pattern from first principles
- deleted 3y ago[deleted]
- _nalply 3y agoWhich programming language is that?
- latchkey 3y agoFirst comment in the first example says: // We're using an imaginary programming language here. Sadly, not answering the 'why'.
- ac2u 2y agoI think it's actually a good move here, using a real language would invite too many comments getting caught in the weeds along the lines of: "actually the language does X, Y and Z to implement coroutines which this article skips over"
- latchkey 2y agoAgreed. My comment was more relating to the fact that comments about 'what' something is, aren't as helpful as answering the 'why', which you just did. =)
- Dobiasd 2y agoThanks for the feedback! I just extended the comment to touch on the "why" part. :) https://github.com/Dobiasd/articles/commit/53f360259ad8e64ca71f8626805cb674c6f60e03 https://github.com/Dobiasd/articles/commit/53f360259ad8e64ca...
- latchkey 2y agoDon't leave me hanging, too specific about what?
- happytoexplain 2y agoI'm not sure if you're actually suggesting that the author expound further on the concept of pseudocode, or if this is just humor.
- latchkey 2y agoMostly humor, but also a suggestion. Why? Because if it was real code I'd want the 'why' to be as specific as possible. It doesn't have to be a novel, but it also shouldn't be left open for interpretation. Too many times have I gotten some ancient piece of code and cursed the author (sometimes this is even myself) for either not documenting it well or it had a bug or whatnot. "OMG, what were they thinking when they wrote this code?!" I never want to be in the position where someone is cursing me.
- Dobiasd 2y agohttps://github.com/Dobiasd/articles/commit/b5342dd5072480800b1197a75383d4b8d6617ef1 https://github.com/Dobiasd/articles/commit/b5342dd5072480800... Better? :)
- latchkey 2y agoThat is fantastic. Much appreciated on the quick response. You're hired. =)
- Dobiasd 2y agoThanks! Yeah, that was one of the intentions. :)
- _nalply 2y agoI tend to ignore comments in example programs because they look like this: // Set x to 42 x += 42 It's a form of banner blindness. By the way, first I felt a strong Pythonic vibe but then I realized that the colons after the statements were missing. I asked ChatGPT and it said Nim. I opened the Nim homepage and realized that Nim also uses the colons. Then it said it is probably just a form of pseudo-code, and it was right. I reread the whole article to find the clue but never thought to read the commments. Really weird of me. P.S. Did you see the mistake in the comment before you got here?
- latchkey 2y agoYes, immediately. OCD pet peeve of mine.
- happytoexplain 2y agoRegarding the second code snippet - I've never seen this language feature before. Obviously there are things sometimes called generators implemented as structures, where 'step' or 'next' is just a normal method, but is there a real world example of what is shown?
- Dobiasd 2y agoThanks for the feedback! My code snippets in the article don't use any real/existing language. C# for example, is quite explicit with the transformation of generated to state machines, but also does not provide such methods, as far as I know. I've just added a comment explaining this choice: https://github.com/Dobiasd/articles/commit/f44b897f2a4d20aa957775f0ebe1f50fdfd21b8d https://github.com/Dobiasd/articles/commit/f44b897f2a4d20aa9...