Skip to content

Consistency of read() and write() functions. #14608

Closed
@samoconnor

Description

Below is review of current write an read variants in Base.

I propose:

  • deprecate readbytes and readall, replace with read and readstring respectively
  • add filename-as-1st-arg support everywhere

Rationale:

  • "bytes" is the default, write is not writebytes so readbytes should just be read.
  • readall is named as "read_[how much]" but behaves like "read[as type]_" so it should be readstring.
  • filename-as-1st-arg is generally handy, see examples in write(filename::AbstractString, data) #14546

Deprecation and addition indicated by strikethrough and bold below.
Filename = has read(filename::AbstractString...) method.

Function Filename
write
write_[format]_
writecsv yes
writedlm yes
writemime
Function Type Filename Whole File Non Blocking
read_[how much]_
read(io,T) T
readavailable Array{UInt8} yes
readuntil String
readline String
readall String yes yes
read_[as type]_
readbytes Array{UInt8} yes
read Array{UInt8} yes
readstring String yes yes
readlines Array{String} yes
readcsv Array{T} yes yes
readdlm Array{T} yes yes
readdir Array{String} yes yes
readlink String yes yes
read_[and then]_
readchomp(x) = chomp(readall(x)) yes yes

Related:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions