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

extend write docstring #30677

Merged
merged 3 commits into from
Jan 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
jw3126 committed Jan 10, 2019
commit cf9a7b140c6e4a7b0485f7e5ab386d02b275fb6d
2 changes: 1 addition & 1 deletion base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ julia> write(io, "Sometimes those members") + write(io, " write documentation.")
julia> String(take!(io))
"Sometimes those members write documentation."
```
Note that in general the value needs to be wrapped in a `Ref`, but for several basic types this can be skipped as above.
Note that in general the value needs to be wrapped in a `Ref`, but for several basic types this can be skipped as above.
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes it sound like Ref is needed more often than it really is. In practice, most/all types with a sensible binary representation have direct write methods. In fact I'm not even sure this use of Ref is intended; it's buggy and will sometimes write references as their address.

Maybe I'd say "User-defined plain-data types without write methods can be written when wrapped in a Ref".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I changed it. I think there should be a default way to write bitstypes in Base. Whether it is via write(io, Ref(obj)) or another function I don't have a strong opinion about.

```jldoctest
julia> struct MyStruct; x::Float64; end

Expand Down