Hacker News new | ask | show | jobs
by mistercow 671 days ago
> When I find that the only tube of toothpaste left is that special, sentinel toothpaste, then I know it is time to buy more toothpaste. And then I have ample time to do so.

I might suggest phrasing this a little differently. Obviously, when you find that any tube is the only tube left, you know it’s time to buy more toothpaste. The problem is that you realize this early in the morning or right before bed, and so you’re likely to forget. The advantage of the “sentinel toothpaste” is that it continues to remind you after that moment, so that you’ll actually remember when you have time to do something about it.

And I think that captures the key thing about a sentinel value: it captures state in a place where you’re already storing state, without requiring you to wrap the state in some external structure, e.g. putting a sticky note on your mirror or storing a string’s length in a separate field.

1 comments

My under sink cabinet is a mess. For me, I have no idea if someone is my last tube or just that another one is hiding. This way at least if the different tube is the only one I've found within a reasonable time, there is a high probability that it's the last one. Similar to the classic probability example of marbles in bags.