
On Tue, 13 Nov 2007 16:55:18 -0000, "Thomas Worthington" <tww@...1737...> wrote:
Having a hash system would surely *reduce* complexity by making the test for savability at a single point - when closing the document. No other module or programmer need ever worry about marking the document as dirty or subtleties of how undo works; the acid test is "has the tree changed?" and that can be definitively tested at a single point with no chance of a false negative (well, alright, 1 in 2**128 - much less than the chance of a programming error!). It seems to me, at first glance anyway, to be a better way to go about it than having a special flag which each new editing function must remember to poke.
Using a hash is a not a bad idea in itself (it's how git works, for one example) but I don't think it's the best solution here.
I, too, find the idea of a special flag objectionable. But the undo list is directly pertinent to "has the tree changed?". If we want to eliminate the flag, the simplest thing to do is to check whether the current entry in the undo history was also current at the time the document was last saved. This is less expensive than computing a hash, and does not require establishing a particular normalized serialization of the document. It does require assigning unique ids to undo entires (and making sure that merging via _maybe_done results in a different id), but that's relatively trivial to implement.
-mental