Hacker News new | ask | show | jobs
by e40 1822 days ago
And is another way to say this "side-effect free"?
1 comments

The Linux shell command 'touch foo' is idempotent, but not side-effect free.

Reading a variable shared between threads without a lock is side-effect free but not idempotent.

Interestingly, `touch` is not idempotent because it modifies timestamps. Not being pedantic, just an interesting consideration. `mkdir -p` is idempotent, I believe.
You're absolutely correct, it's not idempotent for the crucial reason you mention. It's crucial because updating the timestamps is the main purpose of 'touch' in the first place!
Reading a variable isn't side-effect free either :P
In the sense that you're moving data in to a register and updating the program counter?
And potentially changing the contents of processor caches.
Opening Schrodinger's box isn't side-effect free. :)