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

What is the correct behavior of Stdin.readByte? #126

Open
joshgoebel opened this issue Sep 24, 2021 · 0 comments
Open

What is the correct behavior of Stdin.readByte? #126

joshgoebel opened this issue Sep 24, 2021 · 0 comments

Comments

@joshgoebel
Copy link
Contributor

joshgoebel commented Sep 24, 2021

Working on new File IO abstractions and found this TODO issue:

if (__buffered != null) {
        // TODO: Is this correct for readByte()?
        // Emit the last remaining bytes.
        var result = __buffered
        __buffered = null
        __waitingFiber.transfer(result)

This behavior is clearly incorrect. If the input closes then the last call to readByte will return a string with all remaining buffered data (or an empty string), not a byte. This begs the question of what SHOULD happen? I would suggest that repeat calls to readByte should continue to return bytes until either null (is returned repeatedly) or a Fiber.abort is triggered.

This is the same question as with readLine on whether reaching the EOF should be an error condition or not.

Related: #125

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

No branches or pull requests

1 participant