Idempotency in the Wild

2023-May-07

I learned about idempotence when reading some blog post about Lisp. It is used to denote operations which have the same effect for any number of times they are executed. For example, emptying a glass of water.

I came across a neat real-life example of an idempotent system on my bus ride to home after classes. There is a chord that runs through the length of the bus which the riders can pull to request the driver to stop at the next stop. When a rider pulls the chord, it immediately makes a loud announcement on the speakers to notify all the riders that the bus is about to stop. Until the bus arrives at the next stop, subsequent chord pulls will not make any announcement but instead flash a stop requested sign on the LED display to signal that the driver is aware of the stop request. Thereby, any number of stop requests will make only one announcement.

stop-requested.jpg
Figure 1: stop requested sign