pathnames
BRIAN SPILSBURY
zhivago@iglou.com
Sun, 11 May 1997 03:04:25 -0400 (EDT)
> Chris Bitmead uid writes:
> > Take the example of a document with several chapters. You've probably
> > got in mind some Lisp function which changes a "Chapter" object and
> > saves it to the disk. Something clever in the background makes sure
> > the old version is saved somehow.
Simpler and more scalable for the object in question to itself hold
the previous revision. Otherwise you'll need to inform the underlying memory
system about versioning. Do you really want to do that?
> > I've got in mind a function (chapter-edit) which takes a "Chapter" as
> > argument and returns a new Chapter object as a result. The old version
> > is not changed in true functional style. Another function (book-edit)
> > takes a "Book" object as argument, and then calls (chapter-edit) to
> > modify chapters. Instead of modifying the book object, (book-edit)
> > makes a new book with the all the latest versions of the chapters and
> > returns the new book object. The old version of the book object is
> > left as-is. (In functional style)
Probably easier to make a copy of the chapter, destructively modify
the original to contain the new data, and then have a link to the
previous version. Otherwise you're restricted to accessing the current
version of the book via some kind of registry or other.
> Unless one restricts completely to an object oriented subset of Common
> Lisp, I'd believe that anything along the above lines would be
> unworkable. Either the user, the programmer or the system would have
> to track down all references to the old ch7 and either leave them or
> rewrite them to point to the new ch7. This would include all lists of
> book and or publications and or chapters that I happen to have kept
> around anywhere at all.
Yeah, you'd want some kind of destructively modifiable container, but
a list or array, or struct would do nicely.
(defstruct chapter (data nil) (ver 0) (previous-version nil))
But then objects aren't terribly functional, they're ways to wrap up
bundles of incremental side-effects.
On the other hand you could ask the garbage collector about it, but
ugh. :)
Brian