4 ms·
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 n
by rcfox 5y ago
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.
- omegalulw 5y agoReading a variable isn't side-effect free either :P
- zomglings 5y agoInterestingly, `touch` is not idempotent because it modifies timestamps. Not being pedantic, just an interesting consideration. `mkdir -p` is idempotent, I believe.
- mytailorisrich 5y agoYou'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!
- deleted 5y ago[deleted]