What recomputes
A change doesn't redraw the whole page. Each variable remembers which variables it read, and
only the ones that read a changed variable run again. Here, count adds one to a counter every
time a variable runs.
Things to try
- Change
c. Onlyproductruns.sumdoesn't readc, so its count stays put. - Change
aorb. Both run:sumreads them, andproductreadssum. - Count the reads.
sumis shown twice and read byproduct, yet it runs once per change. The first read computes it, and the others get the cached value.
How it's built
- Two
<t-let>s wrap their expressions incount. Without it, they'd bea + bandsum * c. countis a registered function that sets a variable as a side effect, so the counters are ordinary variables that<t-out>can show.