[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dumping data structures with circular references.

    Date: Thu, 2 Nov 89 16:26:13 EST
    From: gavan@cmx.npac.syr.edu (Gavan Duffy)
       From: "RDP%ALAN.LAAC-AI.Dialnet.Symbolics.COM %ALAN.kahuna.DECNET.LOCKHEED.COM"@warbucks.ai.sri.com
       Date: Thu, 2 Nov 89 13:05:36 CST
       I'd like to know what people do in general to avoid the "circular
       reference" problem when using SYS:DUMP-FORMS-TO-FILE.  I would guess
       that this must have been solved many times but the documentation doesn't
       seem to have anything to say about it.  
    IWBNI someone could devise a more general solution so we wouldn't have
    to worry about it.

ANSI Common Lisp specifies a general solution to this, the MAKE-LOAD-FORM
generic function.  Briefly,

  Define a new generic function named MAKE-LOAD-FORM, which takes one
  argument and returns two values.  The argument is an object that is
  referenced as a constant or as a self-evaluating form in a file being
  compiled by COMPILE-FILE.  The objective is to enable LOAD to
  construct an equivalent object.

  The first value, called the "creation form," is a form that, when
  evaluated at load time, should return an object that is equivalent to
  the argument.
  The second value, called the "initialization form," is a form that,
  when evaluated at load time, should perform further initialization of
  the object.  The value returned by the initialization form is ignored.

  The creation form for an object is always evaluated before the
  initialization form for that object.  When either the creation form or
  the initialization form references other objects of user-defined types
  that have not been referenced earlier in the COMPILE-FILE, the
  compiler collects all of the creation and initialization forms.

Separating the operation into two forms, unlike :FASD-FORM, makes it
possible to deal with circular structures, since the loader can first
evaluate all the creation forms to create the objects then evaluate all
the initialization forms to fill in the inter-object references.

You should let Symbolics know whether you want this implemented in
Genera 8.0, whether you want it for both Flavors and CLOS or only for
CLOS, and how high you rate its importance.  Be specific, mention some
other feature that you would be willing to sacrifice in order to get
this one.  Genera 8.0 is just about to go into beta test, so this is
the time to get your final input in.

Your input can help us a lot when making decisions on where to put our
resources, and whether to develop new features or improve the quality
of old features.