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

fs_{read,write}: make offset argument optional and default it to -1 #490

Merged
merged 1 commit into from
May 11, 2020

Conversation

squeek502
Copy link
Member

The magic -1 was not very user friendly and wasn't documented, and making it an optional argument makes the most sense to me. This is fully backwards compatible, and will also error on cases where the offset could be used as a callback, but the user probably didn't intend it to be the callback, like:

uv.fs_read(fd, 32, function() end, function() end)

which will give the error

bad argument #3 to 'fs_read' (number expected, got function)

The magic -1 was not very user friendly and wasn't documented, and making it an optional argument makes the most sense to me. This is fully backwards compatible, and will also error on cases where the offset could be used as a callback, but the user probably didn't intend it to be the callback, like:

    uv.fs_read(fd, 32, function() end, function() end)

which will give the error

    bad argument luvit#3 to 'fs_read' (number expected, got function)
@squeek502 squeek502 merged commit 6ccddc4 into luvit:master May 11, 2020
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 this pull request may close these issues.

2 participants