Karol
If you can solve problem of enumerating structures in your image (or
do not really need to do so), it would be nice to have a general
function which returns at least some metadata of structure. Maybe this
can be done with inspector. E.g., SLIME source shows that structures
(at least some of them) may be converted to alist with
> (nth-value 2 (sb-impl::inspected-parts (make-xxx :yy 1))) ; where xxx is a defined structure
((YY . 1) (ZZ))
> (sb-impl::inspected-parts (find-class 'xxx))
shows structure class.
Hmm, I can see no conc-name here... I'm afraid it is not stored. To
fix this, you'll need custom version of defstruct which saves conc-
name somewhere.
Got no more time it now, but I'm sure if you make some portable code
to deal with structures, it will bring some glory for you (maybe this
is done already, but I don't know) and make a lisp better.
uninterning seems like a good idea.
I think SBCL has something like sb-vm::map-allocated-objects...
(defun collect-all-objects-of-type (type)
(assert (not (eq type 'cons)) () "unable to count conses as we're
collecting them to list. Collect conses to vector!")
(let (obj-list)
(loop for space in '(:static :dynamic :read-only)
do
(sb-vm::map-allocated-objects (lambda (o tag bytes)
(declare (ignorable tag bytes))
(when (typep o type)
(pushnew o obj-list)))
space))
obj-list))
But it does not solve your problem. You need collect and replace not
the structures themselves, but the _references_ to them. GC can do
this, while map-allocated-objects can't.
> I know I could quit and start the system again but that seems too
> unlispy. However, I don't know what should happen to already created
> instances of structure?
(setf (find-class 'some-struct) nil)
--
The great peril of our existence lies in the fact that our diet consists
entirely of souls. -- Inuit saying
>> (setf (find-class 'some-struct) nil)
> Wrong. Does not work at all in SBCL and Lispworks:
> 1. Structure constructior and slot accessors are not destroyed.
> 2. make-some-structure returns instance of a structure
> 3. (type-of (make-some-structure)) returns 'some-structure the same
> thing it returned prior to
> (setf (find-class 'some-struct) nil)
Shouldn't pose a problem for the purpose of replacing a structure with a
class.
Hard to obliterate a structure completely due to accessors getting
inlined.