2 ms·
I've currently got a toy language on the go (learning LLVM) and decided to have generators/coroutines as a core part of the language. What I realized is that a
by zamalek 12y ago
I've currently got a toy language on the go (learning LLVM) and decided to have generators/coroutines as a core part of the language.
What I realized is that a function's stack frame is little more than a struct living on the stack - once you have that it makes coroutines somewhat more straightforward to encapsulate. There are some oddities (e.g. the callee's frame is hoisted to the caller's frame, or you sometimes need the frame living on the heap).
I put some pseudo-c together as an end-goal for the toy compiler[1]. Thought this is an interesting approach, comments are appreciated.
[1]: https://gist.github.com/jcdickinson/af7fabf37c808d8e5814 https://gist.github.com/jcdickinson/af7fabf37c808d8e5814