I guess this might be expected since we have a loop, but that makes ResumableFunctions practically useless for IO iterators.
Anybody has a better idea?
I don’t see an example with open or try-finally in the docs, so it’s not explicitly supported. “Top level” in the caveat means that you can’t have any local scope-introducing blocks, like for loops, so I’d be surprised if it were. open(...) do ... won’t work because anonymous functions are explicitly unsupported. I don’t see an explicit mention in the other caveats, but it doesn’t do named nested functions or closures either.
The goal is to automatically generate a state machine from a function definition block with an intuitive loop structure. A scheduled Task put!-ing objects into a Channel does that, but the scheduling is unnecessary overhead for iteration. Even if you’re willing to write out iterate, it’s not trivial in general to describe and maintain the stack frame in a struct. ResumableFunctions only went so far.