On Mon, 18 Nov 2024 at 18:02, Romain Doumenc <romain@trout.software> wrote:
> Hi Roger, > > Glad you found this interesting, and thank you for reading ! > > One can obviously always use methods on a structure instead of > coroutines (in the example I provided, the state could be stored in > the tokenizer), and the question is when storing the state on the Go > stack directly makes code more readable That's not quite what I meant. I was suggesting exactly storing the state on the Go stack, just as you're doing with your coroutines, but instead of using the internal Go API, ISTM that it should be possible to use iter.Pull <https://pkg.go.dev/iter#Pull>, which uses coroutines under the hood, instead. Here is a sketch of the idea: https://go.dev/play/p/pFHvaSgOn9c cheers, rog. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CAJhgaciiHAH_heceV2R8ozveVzg6GrVdBfrhNoOv2uKdOo8Cew%40mail.gmail.com.