3 ms·
I think that's an aliasing question. If write is sending bytes to somewhere else, it's pure. In exactly the same way that returning a value type from a functio
by JonChesterfield 3y ago
I think that's an aliasing question.
If write is sending bytes to somewhere else, it's pure. In exactly the same way that returning a value type from a function is pure, or passing a value type to some other function is pure. Since they're all the same thing. A unix process is a function in a literal sense.
If you've aliased read and write to the same thing then mutation is back with us and sorrows return.
Vaguely tangential, it's totally possible to write a program that uses read() to copy all of stdin to its own address space allocated with brk(), does whatever maths it wants, then sends some of the result back out with write(). Three syscalls, useful userspace program, no libc involved.