Page 180 Table of Contents Index Page 182
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E



CHAPTER 21. INCREMENTAL REDISPLAY

It is also valid to give the :cache-value and not the :unique-id. In this case, unique ids are
just assigned sequentially. So, if output associated with the same thing is done in the same order
each time, it isn't necessary to invent new unique ids for each piece. This is especially true in
the case of children of a cache with a unique id and no cache value of its own. In this case, the
parent marks the particular data structure, whose components can change individually, and the
children are always in the same order and properly identified by their parent and the order in
which they are output.

A unique id need not be unique across the entire redisplay, only among the children of a given
output cache; that is, among all possible (current and additional) uses made of updating-output
that are dynamically (not lexically) within another.

To make incremental redisplay maximally efficient, the programmer should attempt to give as
many caches with :cache-value as possible. For instance, if the thing being redisplayed is a
deeply nested tree, it is better to be able to know when whole branches have not changed than
to have to recurse to every single leaf and check it. So, if there is a modification tick in the
leaves, it is better to also have one in their parent of the leaves and propagate the modification
up when things change. While the simpler approach works, it requires CLIM to do more work
than is necessary.

The following function illustrates the standard use of incremental redisplay:
 
 (defun test (stream)
   (let* ((list (list 1 2 3 4 5))
          (record
            (updating-output (stream)
              (do* ((elements list (cdr elements))
                    (count 0 (1+ count)))
                   ((null elements))
                (let ((element (first elements)))
                  (updating-output (stream :unique-id count
                                           :cache-value element)
                     (format stream "Element ~D" element)
                     (terpri stream)))))))
     (sleep 10)
     (setf (nth 2 list) 17)
     (redisplay record stream)))
When this function is run on a window, the initial display will look like:

 Element 1
 Element 2
 Element 3
 Element 4
 Element 5
After the sleep has terminated, the display will look like:


Page 180 Table of Contents Index Page 182
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E