janet-lang / janet

A dynamic language and bytecode vm
https://janet-lang.org
MIT License
3.38k stars 217 forks source link

(doc next) doesn't mention fiber #1333

Closed iacore closed 7 months ago

iacore commented 7 months ago

next can be used on fiber, but the doc text doesn't mention that.

❯ janet
Janet 1.32.1-1ccd544b linux/x64/gcc - '(doc)' for help
repl:1:> (doc next)

    function

    (next ds &opt key)

    Gets the next key in a data structure. Can be used to iterate 
    through the keys of a data structure in an unspecified order. Keys 
    are guaranteed to be seen only once per iteration if they data 
    structure is not mutated during iteration. If key is nil, next 
    returns the first key. If next returns nil, there are no more keys 
    to iterate through.

nil
repl:3:> (def a (file/lines (file/open "/etc/passwd")))
<fiber 0x555844673640>
repl:4:> (next a nil)
0
repl:5:> (next a 0)
0
repl:6:> (next a 1)
0
repl:7:> (next a 2)
0
repl:8:> 

It says

Keys are guaranteed to be seen only once per iteration if they data structure is not mutated during iteration.

iacore commented 7 months ago

@bakpakin it is not completed by #1334