Why do ChangeSets sort?

Richard A. O'Keefe ok at cs.otago.ac.nz
Tue Feb 25 01:47:42 UTC 2003

Daniel Vainsencher <danielv at netvision.net.il> made some helpful suggestions
about changes.

As a matter of fact, the problemis not so much that
"ChangeSets have only the latest of each [change], and out of order"
as that they DON'T.

More precisely, there are two things.  There is a ChangeSet inside Squeak.
That's a *set* of changes.  And there is a "change set" filed out, outside
Squeak.  That _isn't_ a set of changes, it's a *sequence*.

It's a "declarative" idea with an "imperative" implementation which doesn't
quite work.

The way I was putting it, the original imperative sequence was not being
reproduced, but a *different* imperative sequence.  But another way to put
it is that a set of changes represents a *single* logical update which has
to be applied all at once, and loading a change set doesn't do that.

The symptom I had was that the initial state before applying the sequence
of changes was consistent, and the final state, had it been reached, would
have been inconsistent, but that there was an inconsistent intermediate
state, and the system tried to run the code while it was in that inconsistent
intermediate state.

Suppose we chop a change set into three pieces:  preamble, body, and
postamble.  I'm not concerned here with the parts where people can place
doits of their own, but with the body.  The body of a change set is a set
of additions, renamings, removals &c, such that if you applied all those
changes to the initial state *without* probing intermediate states you
would arrive at the desired final state.

The obvious way to do this is

    system' := system virtualCopy.
    [body isFinished] whileFalse: [
        delta := body nextChange.
        system' applyDelta: delta].
    system installAtomically: system'

so that the deltas would be applied to a (virtual) copy of the system,
and all the code running while this is going on would still be working
in the *original* system.  Only when all the deltas in the body had been
applied would the changes be installed.

Note once again:  I am *not* advocating a change to the system, just tossing
ideas around.

Undo/redo would be nice, but a way of patching the collection classes
without bringing the system down in ruins is all I really need.

More information about the Squeak-dev mailing list