Dependencies

One of the most advanced and delicate piece of Gnumeric is the system
that tracks dependencies, i.e., keeps track of what cells depend on
what other cells. The data structure has to be able to quickly answer
questions like “what cells depend directly and indirectly on
cell A1?”. Building the structure also needs to be fast so large sheets load reasonably fast.

The most obvious choice — a simple per-cell list of
direct dependents — simply does not work well, for example when
someone enters
a formula like =MAX(A1:T50000); you probably do not want to create a
million little lists for that.

Add in dynamic dependencies — A1=”B42″ and A2=INDIRECT(A1) — and
already complicated code gets worse. (Lots of people like to
use INDIRECT even though in my experience it is always the wrong
function to use. Some of the table lookup functions are generally
conceptionally much better suited and avoid that computed-goto
style code.)

A tiny mistake and while
our test sheets may work perfectly fine, someone else’s do not.
Oh, yeah, I have been mucking with that code this weekend.