loops and iterators
TLDR
- iterators are included, as their only used with loops
- the parallel iterator is in asyncParMem
links
TODOs
- nim by example: closure iterators
- iterToProc
loop/iterator related procs
- finished determine if a first class iterator has finished
- countup == .. == ..< (zero index countup)
- countdown == ..^ == ..^1 (zero index countdown)
- items for i blah.items: always called if only 1 identifer is used
- pairs for i,z blah.pairs: always called if two identifiers are used
- low(blah) .. high(blah)
- lines(somefile) each line in the file
iterators
- inlined at the callsite when compiled
- do not have the overhead from function calling
- prone to code bloat
- useful for defining custom loops on complex objects
- can be used as operators if you enclose the name in back ticks
- can be wrapped in a proc with the same name to accumulate the result and return it as a seq
- distinction with procs
- can only be called from loops
- uses yield instead of return keyword
- doesnt have an implicit result
- dont support recursion
- cant be forward declared