@mratsim: Could you elaborate on the third option, please? The following doesn't compile: iterator foo[T](s: seq{call,`let`}[T]): T = var i = 0 while i < s.len: yield s[i] inc i
Whatever the correct syntax is, wouldn't this restrict potential arguments to be immutable even beyond the scope of the for? It also wouldn't work for custom data structures unless they are deep-copied on assignment.