Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(doc next) doesn't mention fiber #1333

Closed
iacore opened this issue Dec 2, 2023 · 1 comment · Fixed by #1334
Closed

(doc next) doesn't mention fiber #1333

iacore opened this issue Dec 2, 2023 · 1 comment · Fixed by #1334

Comments

@iacore
Copy link
Contributor

iacore commented Dec 2, 2023

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.

  • a fiber is not commonly known as "data structure"
  • the fiber self-mutates. "mutated during iteration" is closer to "mutated from the outside"
@iacore
Copy link
Contributor Author

iacore commented Dec 3, 2023

@bakpakin it is not completed by #1334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant