From 35f805f91d7ac55f035e2dd4a69a5e615729663a Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Tue, 16 May 2023 17:24:44 +0200 Subject: [PATCH 1/4] Docs: simple docstring for `write(filename::AbstractString, x)` --- base/io.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/base/io.jl b/base/io.jl index 9c00c57576bac..91f708d43f2b7 100644 --- a/base/io.jl +++ b/base/io.jl @@ -224,7 +224,6 @@ read(stream, ::Type{Union{}}, slurp...; kwargs...) = error("cannot read a value """ write(io::IO, x) - write(filename::AbstractString, x) Write the canonical binary representation of a value to the given I/O stream or file. Return the number of bytes written into the stream. See also [`print`](@ref) to @@ -458,6 +457,14 @@ wait_close(io::AbstractPipe) = (wait_close(pipe_writer(io)::IO); wait_close(pipe # Exception-safe wrappers (io = open(); try f(io) finally close(io)) + +""" + write(filename::AbstractString, x) + +Write `x` to a file, which will be created if it does not exist yet. + +Return the number of bytes written into the stream. +""" write(filename::AbstractString, a1, args...) = open(io->write(io, a1, args...), convert(String, filename)::String, "w") """ From d1d2e60179805e583a5ba3e05ba64206971dfc87 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Tue, 16 May 2023 17:29:47 +0200 Subject: [PATCH 2/4] use `content` instead of `x` --- base/io.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/io.jl b/base/io.jl index 91f708d43f2b7..bc6f0edef9b5c 100644 --- a/base/io.jl +++ b/base/io.jl @@ -459,9 +459,9 @@ wait_close(io::AbstractPipe) = (wait_close(pipe_writer(io)::IO); wait_close(pipe """ - write(filename::AbstractString, x) + write(filename::AbstractString, content) -Write `x` to a file, which will be created if it does not exist yet. +Write `content` to a file, which will be created if it does not exist yet. Return the number of bytes written into the stream. """ From 4a8be0d9418c93ae13bdafb1177d82375645a589 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 31 May 2023 21:45:19 +0200 Subject: [PATCH 3/4] Update base/io.jl Co-authored-by: Jameson Nash --- base/io.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/io.jl b/base/io.jl index bc6f0edef9b5c..90bde8320acf8 100644 --- a/base/io.jl +++ b/base/io.jl @@ -461,7 +461,7 @@ wait_close(io::AbstractPipe) = (wait_close(pipe_writer(io)::IO); wait_close(pipe """ write(filename::AbstractString, content) -Write `content` to a file, which will be created if it does not exist yet. +Write the canonical binary representation of `content` to a file, which will be created if it does not exist yet or overwritten if it does exist. Return the number of bytes written into the stream. """ From 4b1c07b7a20e99765e15c8019f556b72ba156dc7 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 1 Jun 2023 11:17:22 -0400 Subject: [PATCH 4/4] Update base/io.jl --- base/io.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/io.jl b/base/io.jl index 90bde8320acf8..2f7ec595f0dc2 100644 --- a/base/io.jl +++ b/base/io.jl @@ -463,7 +463,7 @@ wait_close(io::AbstractPipe) = (wait_close(pipe_writer(io)::IO); wait_close(pipe Write the canonical binary representation of `content` to a file, which will be created if it does not exist yet or overwritten if it does exist. -Return the number of bytes written into the stream. +Return the number of bytes written into the file. """ write(filename::AbstractString, a1, args...) = open(io->write(io, a1, args...), convert(String, filename)::String, "w")