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(::IO, ::Ref) should be a method of read! #21592

Closed
JeffBezanson opened this issue Apr 27, 2017 · 6 comments · Fixed by #22456
Closed

read(::IO, ::Ref) should be a method of read! #21592

JeffBezanson opened this issue Apr 27, 2017 · 6 comments · Fixed by #22456
Labels
deprecation This change introduces or involves a deprecation io Involving the I/O subsystem: libuv, read, write, etc.
Milestone

Comments

@JeffBezanson
Copy link
Member

This mutates the Ref so should have a !.

@JeffBezanson JeffBezanson added deprecation This change introduces or involves a deprecation io Involving the I/O subsystem: libuv, read, write, etc. labels Apr 27, 2017
@JeffBezanson JeffBezanson added this to the 1.0 milestone Apr 27, 2017
@vtjnash
Copy link
Member

vtjnash commented Apr 27, 2017

Or make it a method of unsafe_read instead?

@JeffBezanson
Copy link
Member Author

It seems equally safe as read! with an array argument, which we also have.

@vtjnash
Copy link
Member

vtjnash commented Apr 27, 2017

Except that Ptr <: Ref

@JeffBezanson
Copy link
Member Author

Ah yes, that continues to confuse me. I think any operation that can write to a Ptr needs to contain unsafe_ if at all possible. So I think this should also be split into two methods. All in all I'd like:

  • Define read!(::IO ::RefValue).
  • Since unsafe_store! has a !, unsafe_read probably should too, so rename to unsafe_read!.
  • Replace read(::IO, ::Ref) with unsafe_read!(::IO, ::Ptr).

This implies that Ptr should not really be a subtype of Ref, since otherwise any function with a ::Ref argument needs to have unsafe in its name. If we change that, then we can have read!(::IO, ::Ref).

@vtjnash
Copy link
Member

vtjnash commented Apr 28, 2017

otherwise any function with a ::Ref argument needs to have unsafe in its name

only if it then proceeds to call unsafe on that argument, in which case, of course? It's not unsafe to have a Ptr, only to load/store it

@JeffBezanson
Copy link
Member Author

Yes, that's true. But I don't think you should have to call unsafe_read! to safely fill a RefValue. Bottom line, using the same generic function name where some argument cases are safe and others are unsafe is not ideal.

JeffBezanson added a commit that referenced this issue Jun 21, 2017
deprecate `read(io, type, dims)`, fix #21450
JeffBezanson added a commit that referenced this issue Jun 21, 2017
deprecate `read(io, type, dims)`, fix #21450
JeffBezanson added a commit that referenced this issue Jun 21, 2017
deprecate `read(io, type, dims)`, fix #21450
JeffBezanson added a commit that referenced this issue Jun 30, 2017
deprecate `read(io, type, dims)`, fix #21450
JeffBezanson added a commit that referenced this issue Jul 7, 2017
deprecate `read(io, type, dims)`, fix #21450
JeffBezanson added a commit that referenced this issue Jul 9, 2017
deprecate `read(io, type, dims)`, fix #21450
jeffwong pushed a commit to jeffwong/julia that referenced this issue Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants