From: Mr. Mark Interrante
Subject: Question about selectively clearing memory...
Date: 
Message-ID: <1993Feb19.013805.13930@uxmail.ust.hk>
I need the capability to create a package; allow the user of a system
to create some state, and then clear out the package and start over
again.  Any ideas on how to selectively unintern only the local
symbols and not all the interesting ones that happen to have been
imported from other packages?  Thanks,

Mark Interrante
···@uxmail.ust.hk
From: Barry Margolin
Subject: Re: Question about selectively clearing memory...
Date: 
Message-ID: <1m2c8fINNbit@early-bird.think.com>
In article <······················@uxmail.ust.hk> ···@uxmail.ust.hk (Mr. Mark Interrante) writes:
>I need the capability to create a package; allow the user of a system
>to create some state, and then clear out the package and start over
>again.  Any ideas on how to selectively unintern only the local
>symbols and not all the interesting ones that happen to have been
>imported from other packages?  Thanks,

After you create the package, generate a table of all the symbols in it
with DO-SYMBOLS.  To clear it out, unintern the symbols that aren't in the
table.

(defvar *initial-symbols-table* (make-hash-table :test #'eq))

(defun save-initial-state ()
  (do-symbols (s 'my-package)
    (setf (gethash s *initial-symbols-table*) t)))

(defun restore-initial-state ()
  (do-symbols (s 'my-package)
    (unless (gethash s *initial-symbols-table*)
      (unintern s 'my-package))))
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar