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

Read/Write method of DataBuffer is against intuition #510

Open
kevinhuangwl opened this issue Jan 7, 2024 · 1 comment
Open

Read/Write method of DataBuffer is against intuition #510

kevinhuangwl opened this issue Jan 7, 2024 · 1 comment

Comments

@kevinhuangwl
Copy link

Naturally when using DataBuffer.read(sth), should expect it to read from sth into the buffer, and vice versa.

But the API of DataBuffer is now just the opposite

@karllessard
Copy link
Collaborator

karllessard commented Jan 11, 2024

Yeah, I tend to agree with you... if I recall correctly, the reasoning behind this was to match the API of the standard NIO buffer, where the get method (so a "read" operation) writes to a destination buffer, while the put method (write operation) reads from a source.

I think the confusion in NdArray is that it is not clear to which subject is attached the action read/write. How you describe it, the subject is the buffer itself, while in reality it is the caller who is taking the action to "read" or "write" to/from the buffer, the same way that it is the caller who makes the action to "get" or "put" a value.

Renaming them to readTo and writeFrom would make that clearer and would have less impact to existing users than simply switching their name.

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

2 participants