RecursivelyNILDoc.tioga
Bob Hagmann May 15, 1986 7:51:11 am PDT
RecursivelyNIL
CEDAR 6.1 — FOR INTERNAL XEROX USE ONLY
RecursivelyNIL
Bob Hagmann
© Copyright 1985 Xerox Corporation. All rights reserved.
Abstract: RecursivelyNIL will take a REF, and recursively processes all objects reachable from the REF. For each object encountered, all REF containing fields are NILed. A callback is provided to limit the destruction.
Created by: Bob Hagmann
Maintained by: Bob Hagmann <Hagmann.pa>
Keywords: nil data structures
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
RecursivelyNIL.NILRef will take a REF ANY to a structure, and recursively processes all objects within the structure and NIL out all REFs inside any reachable object. This is useful for programs that build a complicated data structure, and now are "done" with it.
RecursivelyNIL will not go inside finalizable objects (those objects for which SafeStorage.EnableFinalization has been called): it will NIL out references to them, but will not go inside the "package data structure" and destroy it. This helps prevent a "ZCT Disaster". In addition, it will not process inside of ROPEs. NILRef has optional checkProc argument. If not specified, defaults to a procedure that returns TRUE. Otherwise, for every object found and ref inside the object, your CheckProc is called to see if it is OK to NIL out the REF. This allows you to customize the program to avoid NIL of certain types of objects. If you return OKToNIL as TRUE, the field will be NILed and the field will not be followed in the recursive process.
Seven star warning: NILRef really will nil out everything that it reachable from the root. In particular, if it can get to any viewer, it will destroy everything on the screen!
Safety and concurrency: NILRef is supposed to be safe, but there should be no concurrent updates in the structure that it is destroying. I think that it will not violate safety, but may have strange looping behavior if its data structure is changing.