4 ms·
The concepts of referential transparency and idempotence are close, but not quite equivalent. 'Idempotence' is the property that you can run something 1 or 100
by gamache 18y ago
The concepts of referential transparency and idempotence are close, but not quite equivalent.
'Idempotence' is the property that you can run something 1 or 100 times, and there is no difference in post-conditions. "x=1" is an idempotent operation. Idempotent operations can have side-effects.
'Referential transparency' means you can replace an expression with the value it returns, and it makes no difference in post-conditions. The expression "x=1", while idempotent, is not referentially transparent; the expression (in most languages) will return a value of 1, but you cannot replace "x=1" with "1" in your code and expect the same post-conditions. Referentially-transparent expressions cannot have side-effects.