From: Tim Bradshaw
Subject: Dumping definitions of (circular) structures in cmucl 17f
Date: 
Message-ID: <TFB.95May31052633@burns.cogsci.ed.ac.uk>
Given a structure like:

(defstruct node
  (edges '() :type list))

I want to be able to do this:

(defvar *my-graph*
  #s(node :edges ()))

When I try to compile such a file in cmucl it refuses, saying

 "Error in function kernel:make-structure-load-form:
    Structures of type node cannot be dumped as constants."

I've tried various things with make-load-form (which doesn't seem to
work: it seems to have different numbers of arguments than CLTL2
specifies) &c, but to no avail.

Looking in defstruct.lisp it does some stuff with the
structure-class-make-load-form, so I tried changing that slot to be
:just-dump-it-normally in my structure's class, and it *seems* to
work, but I don't see why it should work (or why it shouldn't in
fact).

This must be a problem other people have had. Any ideas?

Thanks

--tim
-- 
Any camel in a storm

From: ········@iexist.flw.att.com
Subject: Re: Dumping definitions of (circular) structures in cmucl 17f
Date: 
Message-ID: <D9G7pM.41w@ssbunews.ih.att.com>
(defmethod make-load-form ((s node) &optional env)
  (declare (ignore env))
  `(make-node :edges ',(node-edges s)))
-- 
----------------
Olivier Clarisse
Member of Technicall Staff
AT&T Bell Laboratories
From: Barry Margolin
Subject: Re: Dumping definitions of (circular) structures in cmucl 17f
Date: 
Message-ID: <3qit68$qqg@tools.near.net>
In article <·················@burns.cogsci.ed.ac.uk> ···@cogsci.ed.ac.uk (Tim Bradshaw) writes:
>Given a structure like:
>(defstruct node
>  (edges '() :type list))
>I want to be able to do this:
>(defvar *my-graph*
>  #s(node :edges ()))
>When I try to compile such a file in cmucl it refuses, saying
> "Error in function kernel:make-structure-load-form:
>    Structures of type node cannot be dumped as constants."
>I've tried various things with make-load-form (which doesn't seem to
>work: it seems to have different numbers of arguments than CLTL2
>specifies) &c, but to no avail.

MAKE-LOAD-FORM and MAKE-LOAD-FORM-SAVING-SLOTS were changed post-CLtL2 to
take an optional environment argument.  The compiler passes this argument
to indicate the lexical environment in which the create and initialization
forms will be evaluated.  If you write a MAKE-LOAD-FORM method it must be
prepared to accept this argument, and if it calls
MAKE-LOAD-FORM-SAVING-SLOTS it should pass it on (I'm not sure what else it
can usefully do with it, since it doesn't receive any forms as arguments).

By the way, your Subject line says "(circular)", but there's nothing
circular in your example.


-- 
Barry Margolin
BBN Planet Corporation, Cambridge, MA
······@{bbnplanet.com,near.net,nic.near.net,netcom.com}
Phone (617) 873-3126 - Fax (617) 873-5124