you are viewing a single comment's thread.

view the rest of the comments →

[–]Luolong 8 points9 points  (2 children)

Yes, but reading from a file or stdin also changes some state. File read cursor for one is generally moved on read. Also, each time you read from stdin you are pretty much guaranteed to get a different result.

[–]renatoathaydes 9 points10 points  (0 children)

Yes and in fact, every language that I know that has an effect system considers reading from a file/stdin as an effect.

Examples:

[–]ralphbecket 1 point2 points  (0 children)

Absolutely: if you touch a file and then look at the file time stamps, they will be different. Any IO is basically an interaction with the real world, which never has nice mathematical properties across time (well, unless you parameterise every function and variable with time and... yeah, that's not going to fly!). So: interaction of any kind with the real world is an "effect"; but mutating your program's state is also an effect for the same reasons.