You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
prociterGen(someEvalOnceArg: int): (iterator (): int {.closure.}) =result=iterator (): int=yield1yield2yield3# this works finelet it =iterGen(42)
for x init():
echo x
# this is an infinite loopfor x initerGen(42)():
echo x
proposal
make for x in expr: ... cache the value of expr to avoid this (maybe using something like sequtils.evalOnceAs)
scratch below
maybe for could be actually implemented in system.nim, now that we have forLoopMacros; maybe this would help in solving this (not sure)
The text was updated successfully, but these errors were encountered:
timotheecour
changed the title
for x in myIter(42)(): ... gives infinite loop; inconsistent with let it = iterGen(42); for x in it(): ...for x in myIter(1)(): ... gives infinite loop; inconsistent with let it = iterGen(1); for x in it(): ...Aug 25, 2018
originally reported here: https://github.com/nim-lang/Nim/issues/7047#issuecomment-390604711
proposal
for x in expr: ...
cache the value ofexpr
to avoid this (maybe using something likesequtils.evalOnceAs
)scratch below
for
could be actually implemented in system.nim, now that we haveforLoopMacros
; maybe this would help in solving this (not sure)The text was updated successfully, but these errors were encountered: