The “official” interpretation is that read(io)
doesn’t mutate io
. It’s the state of the world that changed, not the io
object.
I favor a somewhat larger conception of “publicly visible” than that.
That’s fine, but the Julia designers had to draw the line somwhere on what is explicit state and what is implicit state. There’s always going to be examples where one could argue whether that line might have been better moved a bit in one direction or the other. In some sense, every function mutates, since it changes the content of your RAM or at least the registers in the CPU.
Functional languages like Haskell tend to draw the line for what is explicit state a lot closer and probably would support that read(io)
should be considered mutating. But fundamentally, it’s a language design decision, and Julia is not at that stage of development anymore. So the semantics or name of read
isn’t going to change.
Personally, I find the decisions that were made for Julia quite sensible, but it’s hard to argue if your intuition is different (maybe because you’re coming from a more functional language background?)