A bit less "funky" idea - I currently use it in my https://github.com/cosmos72/gomacro to interrupt the interpreter if the user hits Ctrl+C. Caveat: I don't know how difficult is to adapt it to GoAWK.
The idea is conceptually simple: loop unrolling. The details are slightly tricky: unroll the interpreter main loop that executes statements by something like 20 times, and after the 20 iterations check *once* for externally-set flags: timeout, Ctrl+C, etc. The tricky part is: you also need to handle the case where you are somewhere in the middle of the 20 unrolled iterations but suddenly there are no more statements to execute. The skeleton code might look similar to https://github.com/cosmos72/gomacro/blob/master/fast/code.go#L169 or https://github.com/cosmos72/gomacro/blob/master/fast/code.go#L204 Regards, Cosmos72 -- 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 on the web visit https://groups.google.com/d/msgid/golang-nuts/d7484265-0a61-4c48-9e4e-0d6aaa3d447b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.