← the matrixmodel
Capability — model
Functions as values
A function is a value: you can pass it, store it, return it.
LISP made functions ordinary data in 1958, and everything downstream — closures, callbacks, higher-order methods, the lambda — descends from that one move. If a function is a value, you can compose programs instead of writing them: pass behaviour into a sort, return behaviour from a factory, store it in a table.
It also changed what a program looks like. In a language where functions are values, iteration is a function you hand a behaviour to; collection methods are not language features so much as functions everyone happens to agree on.
The trade-off
- First-class functions cost allocation and identity: a closure needs a home, and two closures created from the same source are not the same object.
- They also make control flow harder to follow — the classic bug is a callback that runs after the thing it was meant to update is gone.
Where it came from
LISP, 1958 — lambda as an object, quotable and storable like any other datum.