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

undocumented 1 argument write #17612

Closed
ggggggggg opened this issue Jul 25, 2016 · 5 comments
Closed

undocumented 1 argument write #17612

ggggggggg opened this issue Jul 25, 2016 · 5 comments
Labels
io Involving the I/O subsystem: libuv, read, write, etc.

Comments

@ggggggggg
Copy link
Contributor

There is a 1 argument write in both 0.4.6 and 0.5.0 that is not described in the docstring or in the online documentation.

@tkelman tkelman added io Involving the I/O subsystem: libuv, read, write, etc. needs docs Documentation for this change is required labels Jul 25, 2016
@JeffBezanson
Copy link
Member

Not clear that this is necessary actually; I'm not sure it's even a good idea to have a shortcut for writing binary data to STDOUT.

@StefanKarpinski
Copy link
Member

I agree. Not having a default output stream seems like a key difference between print and write.

dhoegh added a commit to dhoegh/julia that referenced this issue Jul 27, 2016
dhoegh added a commit to dhoegh/julia that referenced this issue Jul 27, 2016
JeffBezanson added a commit that referenced this issue Aug 9, 2016
Deprecate 1 argument write. fix #17612
@tkelman tkelman removed the needs docs Documentation for this change is required label Aug 9, 2016
mfasi pushed a commit to mfasi/julia that referenced this issue Sep 5, 2016
@ggggggggg
Copy link
Contributor Author

There are still multiple single argument write methods in 0.7.0-DEV.3096, which result from methods which have a splatted 2nd argument.

julia> methods(write,Tuple{Any})
# 3 methods for generic function "write":
[1] write(filename::AbstractString, args...) in Base at io.jl:275
[2] write(io::IO, xs...) in Base at io.jl:488

The first of these causes write("a") to create a file called "a" in the current directory, which seems undesirable.

Perhaps we should define something like:

Base.write(::AbstractString) = error("write requires two arguments")
Base.write(::IO) = error("write requires two arguments")

@StefanKarpinski
Copy link
Member

Probably a good idea to fix. Also unlikely that fixing them will cause anyone grief, but still...

@JeffBezanson
Copy link
Member

Good catch. I think the first one should get an extra argument:

write(filename::AbstractString, a1, args...) = open(io->write(io, a1, args...), filename, "w")

The second one could too, but we also might want to just deprecate vararg write (which just loops over the arguments and calls write on all of them).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

No branches or pull requests

4 participants