Base CS from zero
Variables and state: free-recall review
Recall beats re-reading. For each prompt, say or write a full answer from memory before you open the model answer — the effort of reconstructing the memory model is what makes it stick.
Reconstruct the unit’s spine from memory: what a variable really is, what assignment and mutation do to a cell, what state is, and why copying a primitive differs from copying a reference.
- 01What is a variable, in terms of a name, a binding, and a cell?
- 02Explain assignment as a machine operation, and why '=' should be read as 'gets' rather than 'equals'.
- 03What is mutation, and how does state differ from the history of mutations?
- 04Contrast copy (value) semantics with reference semantics. What sits in the cell in each case?
- 05What is aliasing, why does it cause surprising bugs, and how do you avoid it?
- 06What exactly does const protect, and what does it NOT protect?
If you reconstructed each answer from memory, you hold the unit’s spine: a variable is a name bound to a cell, and the name and value are distinct; assignment is a destructive store read as ‘gets’; mutation changes a cell in place and state is the snapshot of all current cells; primitives copy by value while objects copy by reference, which is what makes aliasing — and the bugs it causes — predictable; and const seals the binding, never the contents behind it.