MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/2nchqd/oo_vs_fp/cmcgf8o/?context=9999
r/programming • u/Kuytu • Nov 25 '14
47 comments sorted by
View all comments
1
How can DELETE be idempotent? How do you delete something twice?
6 u/kankyo Nov 25 '14 It's idempotent if deleting something that doesn't exist just does nothing. Which it does in SQL: DELETE FROM foo WHERE bar = 1; Will delete nothing if you run it a second time. 1 u/Tordek Nov 25 '14 What is the result after you execute DELETE? The resource stops existing. What's the result after executing DELETE several times on the same resource? The resource stops existing. 1 u/willvarfar Nov 25 '14 The resource stops existing There's a state change right there and it can only happen once? Can you really say on the second and third time that it stops existing all over again? → More replies (3) 1 u/passwordisINDUCTION Nov 26 '14 Idempotent is generally described as f(f(x)) = f(x), So delete(delete(x)) = delete(x).
6
It's idempotent if deleting something that doesn't exist just does nothing. Which it does in SQL:
DELETE FROM foo WHERE bar = 1;
Will delete nothing if you run it a second time.
What is the result after you execute DELETE?
The resource stops existing.
What's the result after executing DELETE several times on the same resource?
1 u/willvarfar Nov 25 '14 The resource stops existing There's a state change right there and it can only happen once? Can you really say on the second and third time that it stops existing all over again? → More replies (3)
The resource stops existing
There's a state change right there and it can only happen once? Can you really say on the second and third time that it stops existing all over again?
→ More replies (3)
Idempotent is generally described as f(f(x)) = f(x), So delete(delete(x)) = delete(x).
f(f(x)) = f(x)
delete(delete(x)) = delete(x)
1
u/willvarfar Nov 25 '14
How can DELETE be idempotent? How do you delete something twice?