Engineering / Language interpreter implementation

The little debugger

Trace shared variables, function calls, and a branch whose changes must roll back.

0 creditsHuman example only
Your workbench

Repair two rules in a tiny language machine. An alias names the same cell. A rejected branch must undo both its mutations and its printed output. The accepted branch should finish with x = y = 6 and print just 6.

Eight-line program

  1. 1let x = 2
  2. 2alias y = x
  3. 3define bump(): x = x + 3
  4. 4try: bump(); print x
  5. 5reject that trial
  6. 6accepted: y = y + 1
  7. 7accepted: bump()
  8. 8accepted: print x

Live memory

Variable names, heap cells, and captured functionxy22bump()captured xKept output: []

Create x = 2

1 / 8
Make a change, explore the result, then check your solution.
Need a hint?
Point y at x’s existing cell and restore all cells, aliases, and output on rejection. At line 5, both values return to 2 and the trial’s printed 5 disappears.
Explore another example / 16Reconciliation desk