the old world
-------------
The existing fields hack makes the following assumptions about field values:

  - they're never stored
  - they're never edited
  - they're always calculated
  - they get updated very very often

Indeed, the last time I checked, *all* fields in a document get recalculated 
for *every* change to the document, including undos.  To see this in action, 
open up the following file and start typing:

  abi/test/wp/Gettysburg.abw

For every character typed, that embedded clock updates.  Worse, if you undo 
all of that typing, you don't get back to the original unmodified state of 
the document, because the time gets updated for every undo, too. 

the real world
--------------
By contrast, a little reverse engineering shows that other word processors 
work in a very different way.  Field values get calculated once, and then 
they pretty much stay that way until they're explicitly changed in one of 
the following ways:

  - by editing (typing, selections, etc.)
  - manual update (via a context menu)
  - at print time (updates date, time, and page references)
  - at save time (?? -- requires further testing)

Moreover, *every* one of these changes are undoable.  For the most part, 
field values just sit there, and any time they get changed, you can always 
get back to the prior state of the document.  

note:  we can't skip the first undo
-----------------------------------
The usual response to my initial claim that editing and undo are important 
is that we can just skip editing.  However, we still need to be able to undo 
the following actions:

  - creating the field in the first place
  - deleting it entirely

As it turns out, the change records required to do these operations are no 
more complex than we'd need to also make changes to the field's arguments or 
contents undoable.  For details, see:

  http://www.abisource.com/mailinglists/abiword-dev/00/September/0272.html

In every case, it's a multi-step glob.  Indeed, editing and updates are 
actually *easiera*, because we can sometimes skip one or more of the steps.  

implication
-----------
My initial worry was that updates were very frequent, and that we might want 
to avoid invoking the undo mechanism in some cases.  However, the more I 
dug, the clearer it got -- updates are in fact rare and always undoable. 

Paul



Reply via email to