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!, etc. #5970

Closed
StefanKarpinski opened this issue Feb 26, 2014 · 6 comments
Closed

read!, etc. #5970

StefanKarpinski opened this issue Feb 26, 2014 · 6 comments
Labels
domain:io Involving the I/O subsystem: libuv, read, write, etc. kind:breaking This change will break code
Milestone

Comments

@StefanKarpinski
Copy link
Sponsor Member

Technically, the methods of read that fills a buffer should be named read!. I propose the following:

read(io::IO, T::Type) # read a single value of type T
read!{T}(io::IO, buf::Array{T}) # fill buf with values of type T from io
read(io::IO, T::Type, dims::Int...) = read!(io, Array(T,dims))
@kmsquire
Copy link
Member

I like the consistency. +1

@johnmyleswhite
Copy link
Member

Yes!!! My last attempt to convince Jeff of this failed, but I think this is the cleanest way to go.

@JeffBezanson
Copy link
Sponsor Member

The ! is justified by the argument buf being filled. Other read methods wouldn't have it. If that's what you suggested before, I may have misunderstood.

@johnmyleswhite
Copy link
Member

No, you're right: I was suggesting something broader than this.

@stevengj
Copy link
Member

Yes, please. (Note that we already have readbytes vs. readbytes!.)

@mbauman
Copy link
Sponsor Member

mbauman commented Mar 16, 2014

+1. The current implementation of read{T}(io::IO, buf::Array{T}) is undocumented… I was about to add the documentation, but thought that read! was a better name myself. Glad to see this open issue.

@JeffBezanson JeffBezanson added this to the 0.3 milestone Mar 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:io Involving the I/O subsystem: libuv, read, write, etc. kind:breaking This change will break code
Projects
None yet
Development

No branches or pull requests

6 participants