This is the simplest IO example (copied from AI) and explicitly supported in the docs:
@resumable function read_lines(filename)
io = open(filename)
try
for line in eachline(io)
@yield line
end
finally
close(io)
end
end
Documentation (GitHub - JuliaDynamics/ResumableFunctions.jl: C# style generators a.k.a. semi-coroutines for Julia. · GitHub) says: " * In a try block only top level @yield statements are allowed."
Error I get: ERROR: LoadError: syntax: cannot goto label “_STATE_1” inside try/catch block
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?