3 ms·
> If two invocations of your function with the same parameters both mutate any part of that state, and nothing else mutated that part in between, then it's not
by PaulDavisThe1st 2y ago
> If two invocations of your function with the same parameters both mutate any part of that state, and nothing else mutated that part in between, then it's not idempotent.
Still not accurate. What matters is whether N calls to the function changes the state differently than a single call. If not, then the function is idempotent.
Another issue with idempotency is that there's an implicit temporal component that is rarely explicitly discussed. Most people don't expect a function to necessarily be idempotent over long periods of time.
- happytoexplain 2y ago>What matters is whether N calls to the function changes the state differently than a single call. I thought "any 2" would be the relevant subset of "N" that you can use to define idempotency in simpler terms. Also, I'm using the phrase "mutate state" as shorthand for your "change state differently", I think. I.e. if two things both change state, then by definition they changed it "differently". If two things both set x to 1, the second one didn't "change state". >there's an implicit temporal component ... idempotent over long periods This sounds a bit like what I mentioned about other things touching state between calls to your idempotent function. Maybe I meant the same thing as you, but used different words?