The Day I Learned [vm]
While refactoring Golden Junqi, I encountered a small piece of Swift syntax:
boardView.cardProvider = { [vm] col, row in
vm.game.cardAt(col: col, row: row)
}
After years of writing Swift and building multiple games, I realized I had never really learned what:
[vm]
meant.
At nearly the same moment, the Living Museum visitor counter crossed 400.
The surprising discovery was not that capture lists exist.
The surprising discovery was that the code would often compile perfectly without them.
boardView.onMove = { from, to in
vm.handleMove(from: from, to: to)
}
Swift had quietly been capturing values all along.
The explicit capture list did not add a new capability.
It made an invisible mechanism visible.
Two square brackets suddenly connected several ideas:
ownership
dependencies
closures
architecture
A closure does not need an entire object.
It can capture exactly what it needs.
The BoardView does not need the entire world.
Sometimes it only needs:
[vm]
Programming expertise does not eliminate surprises.
Large systems can be built before small language features are understood.
Sometimes a tiny piece of syntax arrives years late and reorganizes what you already know.
A tiny language feature can influence the architecture of an entire application.
Refactoring creates opportunities for hidden ideas to become visible.
Learning does not end when expertise begins.