Why does `write` not have `!` in its name?

Julia style guide suggests appending an ! to the function’s name. I am curious about why write does not follow this guide? Isn’t write modifying io or filename? What is the boundary of distinguishing modifying or not?

write(io::IO, x)
write(filename::AbstractString, x)

I think it is implicitly understood that write has side effects. Cf rand.

(Note that write of course does not modify filename::AbstractString, just the contents of the file it refers to).

1 Like

I found JuMP.jl style guide. It agrees with you since set_name and add_constraint are clear that modification is taking place.