Just to add that I understand that the iterator can be resumed, so perhaps
freeing resources must not be part of the code of the iterator, though it
should access variables declared in the iterator...
proc main =
let iter = stream(parseInt(paramStr(1)))
for i in iter():
echo "i=", i
if i == 10:
echo "Aborting iteration in main after 10 items..."
sleep(2_000)
break
for i in iter():
echo "i2=", i
echo "Out of iterator in main"
Run
But at least it should be called when the iterator variable becomes out of
scope and that's the reason why I thought I could find something in _Nim
Destructors and Move Semantics_ or compiling with `-gc:arc` but I was unable to
get deallocation of resources.