Re: [go-nuts] Experience Report: Using Coroutines for Parsing

2025-03-26 Thread roger peppe
Glad to hear it worked out for you! rog. On Mon, 24 Mar 2025, 20:06 Jason E. Aten, wrote: > I implemented this iter.Pull strategy for keeping parser state, instead of > using a background goroutine (as I did for years) in my pure Go lisp, > zygomys, > and the resulting code is much easier to r

Re: [go-nuts] Experience Report: Using Coroutines for Parsing

2025-03-24 Thread Jason E. Aten
I implemented this iter.Pull strategy for keeping parser state, instead of using a background goroutine (as I did for years) in my pure Go lisp, zygomys, and the resulting code is much easier to read and follow, and about 12% faster on Linux (although 0.3% slower on Darwin). Details and specif

Re: [go-nuts] Experience Report: Using Coroutines for Parsing

2024-11-18 Thread roger peppe
On Mon, 18 Nov 2024 at 18:02, Romain Doumenc 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 quest

Re: [go-nuts] Experience Report: Using Coroutines for Parsing

2024-11-18 Thread robert engels
Btw, wasn’t being dismissive of your effort - I only linked to the article (which is pretty old) because it covers many of the same ideas you were discussing - and whenever I get the chance to link to something involving Knuth I am going to take it :) > On Nov 18, 2024, at 12:02 PM, Romain Doum

Re: [go-nuts] Experience Report: Using Coroutines for Parsing

2024-11-18 Thread Romain Doumenc
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

Re: [go-nuts] Experience Report: Using Coroutines for Parsing

2024-11-18 Thread robert engels
I agree, all you need is generators - that they are implemented with coroutines is immaterial. Take a look at this, and substitute the yield() function for crReturn(). https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html > On Nov 18, 2024, at 10:54 AM, roger peppe wrote: > > Interesti

Re: [go-nuts] Experience Report: Using Coroutines for Parsing

2024-11-18 Thread roger peppe
Interesting! Thanks for sharing. This is related to something that I've been planning to explore for a while now: using iterators themselves and their associated coroutines accessed via `iter.Pull`, to do parsing. That is, instead of gaining access to the underlying coroutine machinery by use of "

[go-nuts] Experience Report: Using Coroutines for Parsing

2024-11-17 Thread Romain Doumenc
Hi everyone, I took some time over the past weeks to experiment with the coroutine switching capabilities in the runtime – in this case for parsing. I find this new API extremely useful, and started seeing quite a few places in the code base I maintain to simplify some complicated, synchronized,