I understand Nim has closure iterators, and that's really awesome. But sometimes, I would want to store an iterator to a variable and call it in different occasions. For example:
var iter = arg.split("->").filter(proc(s: string): bool = s == target)
This currently allocates an entire seq to my knowledge. However I'd like to just call the iterator instead:
if certain_condition: iter.next() # pop an item and advance
if another_condition: let x = iter.peek() # peek at the next item without advancing
if condition_x: iter.advance_by(3) # advance the iter by 3 "index"
Because Nim has the function local static variables ({.global.} afaik) I don't think it'd be hard to implement but it'd be nice if Nim had this mechanism built-in ootb.