Not all call/cc implementations are exactly the same, but hopefully this answer can be applied to all common options, including Racket with minor problems. This story is actually based on c built-in Unlambda .
Call metaphor / cc
You are a superhero archaeologist on a breakout in old Maya. You open an exquisitely built, perfectly preserved stone doorway in an elegant arch. But this is just a doorway that was laid on its side; there is no wall nearby, and it seems that it has never been part of the wall. Your staff receives energy from him, so you transfer him back to the laboratory for study.
In your laboratory, a large clock hangs on the wall right in front of the now vertical arch that you placed near the middle of the room. Studying the arch, you pass through it.
4:17 pm
Going through the archway, you will now notice, to your surprise, that you are holding a cubic box in your hand, large enough to put the book inside, with a cover and one luminous button. You donβt remember how you picked up such a box or saw it before. You call the assistant and ask where the box comes from. The assistant does not know. If you put the box down, the button will turn off. You pick it up again, the button lights up again. It only glows when you hold it; if the assistant picks up the box, it does not light up. In a lark you put a paper clip in a box, close the lid and press the button.
4:23 PM
Having passed through the arch, you will now notice, to your surprise, that you are holding a paper clip in your hand. You do not remember how to pick it up. Your assistant in the room, looking at you, stunned. You do not remember how your assistant enters the room. It also seems that your watch is several minutes faster.
"What just happened?" asks the assistant.
βI just walked along the arch,β you say, not quite understanding the question.
"No, no! What happened to the box?" says the assistant.
"What are you talking about?" you say grow annoyed.
...
As soon as the whole situation erupts, and you find out what this arch does, you decided to do something bold. You read aloud the current time and go through the arch.
5:30 pm
Leaving the arch, you are holding an empty box. Observing that the time is 5:30 pm, as you expected, you attach a note to the box with the inscription #1 . You put the box on the table, read the current time out loud and again go through the arch.
5:31 pm
Leaving the arch, you are holding an empty box. Observing that the time is 5:31 pm, as you expected, you attach a note to the box with the inscription #2 - use to forget . You put box number 2 inside box number 1 (it shrinks to a fraction of its size as you do this, it seems that boxes are for this purpose).
As a superhero archaeologist, you equip yourself accordingly and break into the foreign embassy of your least beloved repressive regime, breaking through its vaults and stealing paper copies of some of its carefully kept state secrets. Hong Kong action movie, bullets and fists fly. You will barricade yourself in the vault by buying precious seconds before their guards can reach you. Creating box number 1 from your bag, you fill the paper inside (together, but not inside, box number 2, which is also there), close box number 1, and just as the storage door opens, you smile, pull the pin, lower grenade and press the button.
9:45 pm
Leaving the arch, you hold an empty box, which was marked as #2 - use to forget , and documents containing the secret secret secrets of your least favorite repressive regime. You also note that the time is not 5:30 pm, as you expected, but 9:45 pm, so you will not continue your planned hacking plan. You sit down and transfer the contents of the documents to memory, and as soon as you are sure that they are completely remembered, you write the documents into the basket. Now you read aloud the current time and go through the arch.
2:00 AM
Leaving the arch, you are holding an empty box. By observing that the current time is 2:00 AM, as you expected, you will immediately mark the new field #3 - use to remember . You write yourself a short note: Allow self to forget again. At exactly 7:15 PM call police and report suspicious persons at 14th and Maple. Allow self to forget again. At exactly 7:15 PM call police and report suspicious persons at 14th and Maple. Having placed box No. 3 and a note inside box No. 2, you then press the button on box No. 2.
2:01 am
Appearing from the arch, you hold an empty box, which is marked as #3 - use to remember , and a note in your own handwriting. The time is much later than the expected 5:31 pm, so you will not continue your planned hacking plan. Following the instructions for yourself, you again go through the arch, receiving a new box, which you will name #4 - use to forget . You call the police, as you indicated in your note, not knowing why, and hear on news days later than the international spy ring was broken in your hometown.
Mission accomplished! (Assume.) From now on, you have a choice to know the information yourself, but not what you did with it; or not know the information, but know how it was used.
After all, this wonderful tool is expensive. As you continue to rely on the arch in various activities, you must do this, knowing that you will forever fragment your life, and the fragments can never be combined, except by sending messages between your many alternative selves. And a single use of boxes with buttons can lead to the irretrievable loss of many precious memories, which can be either a stratagem or a grave and tragic mistake.
Description
Passing through an arch is a call/cc operation. This leads to the creation of a new button block, which is a continuation function. Putting things in a field represents passing arguments to the continuation function. Pressing a button in a field represents a continuation function call.
Pressing the button on the box (calling the continuation function) will restore the legendary symbol (call stack with variables) to the exact state at the time the field was created (continued), that is, the moment when call/cc initially completed. Arguments passed in the sequel result from the result of the original call/cc after the stack was restored; therefore, by pressing the button, the reference symbol does not store the field, but the contents of the field.
Boxes (continuations) can be encapsulated (transferred to each other), which allows you to use call/cc as a primitive for implementing shared routines, machine states, and other advanced designs.
Continuations can also be used to quickly exit code branches in ways that would otherwise be inconvenient ("drop the grenade, press the button"), for example, instantly exit deeply embedded conventions and loops that cause side effects.
Note also that the arch is not a time machine; time never cancels itself in history, and does nothing external to the legendary character walking along the arch. (Destructive assignments, changes in heap memory, and other side effects do not change, causing the continuation function.)
Exercise: write a pseudo-code for the legendary symbol, which will lead to the fact that the correctly executed espionage plan will be described.