From f44b897f2a4d20aa957775f0ebe1f50fdfd21b8d Mon Sep 17 00:00:00 2001 From: Dobiasd Date: Wed, 20 Mar 2024 14:31:09 +0100 Subject: [PATCH] Explain why the step method is introduced in the snippets --- internals_of_the_async_await_pattern_from_first_principles.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internals_of_the_async_await_pattern_from_first_principles.md b/internals_of_the_async_await_pattern_from_first_principles.md index 3139f5b..96bd914 100644 --- a/internals_of_the_async_await_pattern_from_first_principles.md +++ b/internals_of_the_async_await_pattern_from_first_principles.md @@ -24,8 +24,8 @@ function foo() yield x g = foo() -assert g.step() == 21 -assert g.step() == 42 +assert g.step() == 21 // Stepping the generator might look different in real languages. +assert g.step() == 42 // But to be explicit, our imaginary language provides this method. ``` In many programming languages, the above generator is internally (by the interpreter or compiler) converted to a state machine as follows: