From: R. Giuly
Subject: undbind everything?
Date: 
Message-ID: <3AB573C6.E3707309@hotmail.com>
Is there some way to unbind every symbol that you have bound. Like
exiting lisp and restarting without actually exiting.
(I'm using LispWorks)

-- 
Richard Giuly

(remove animal from email address)

From: Kent M Pitman
Subject: Re: undbind everything?
Date: 
Message-ID: <sfw66h6iet8.fsf@world.std.com>
"R. Giuly" <·········@hotmail.com> writes:

> Is there some way to unbind every symbol that you have bound. Like
> exiting lisp and restarting without actually exiting.
> (I'm using LispWorks)

Yes and no.

LET bindings will be undone when you return to Lisp toplevel, so presumably
you aren't asking about that kind of binding.

The verb unbind is not usually used in the style I'm assuming you're using
it here.  When you assign a variable, you are giving it a binding, but
you are not binding it.  Binding a variable usually implies a containing
form that will both establish and de-establish the binding, such as LET.

If you have clobbered the initial value of some variable that had a value
when Lisp started, the only way to undo that would be to remember what the
old value had been and to set it back.

If you have given new values to things that were previously bound, you can
use MAKUNBOUND for any such symbol.  It's up to you to do the bookkeeping
to know which symbols you need to do this to.

In general, this kind of operator is semantically ill-defined, which is why
it's not offered.  The reason is that if you had a program that needed  to
call this, you might load that program into an environment that had other
tools it didn't know about which didn't want that done to them.  In order
to have one user's program not bash another's, by convention, no program
really should ever take steps that affect all programs because they never
really know what they'll be affecting by so doing.

If, by the way, you just want to delete all the things in a package you've
defined, you can do DELETE-PACKAGE, which comes close to what you want.
This will make those things mostly subject to the GC, though classes and
methods will still be pointed to by the class system itself, so you really
won't get back all the memory you wanted--but you may get the approximate
effect since you can't (easily) get to those classes any more.

Hope this helps.
From: Martin Ginkel
Subject: Re: undbind everything?
Date: 
Message-ID: <9ak9ig$2v8f$1@gwdu67.gwdg.de>
Hi,

> If, by the way, you just want to delete all the things in a package you've
> defined, you can do DELETE-PACKAGE, which comes close to what you want.
> This will make those things mostly subject to the GC, though classes and
> methods will still be pointed to by the class system itself, so you really
> won't get back all the memory you wanted--but you may get the approximate
> effect since you can't (easily) get to those classes any more.

You can also throw away the classes and methods:
* For classes you can (setf (find-class 'xxx) nil)
  (From Ansi CL by Graham)
* For methods first is (rmove-method generic-function method)
* If the generic fuction is empty (no more methods):
  (fmakunbound (generic-function-name generic-function))
* All you have to do now is to find out all symbols with
  (apropos-list "") and then look for 
        -symbol-value (makunbound )
        -symbol-function (fmakunbound )
        -find-class (setf (find-class ))

  In all those packages you want to delete. I do some of the 
  deletions in ACL myself (never a whole package) and they work well
  In the end you should of course (gc) for cleanup.

        Martin

-- 
+-[Martin Ginkel]-----------------[·············@mpi-magdeburg.mpg.de]-+
| MPI Magdeburg, Zi 282 Zenit-Geb. Leipziger Str 44, D-39120 Magdeburg |
| It could be that the purpose of life is serving as warning to others |
+-[tel: +49 391 6117 563]------------[http://www.mpi-magdeburg.mpg.de]-+
From: David Bakhash
Subject: Re: undbind everything?
Date: 
Message-ID: <m3y9tcpies.fsf@alum.mit.edu>
>>>>> "mg" == Martin Ginkel <·············@writeme.com> writes:

 >> If, by the way, you just want to delete all the things in a
 >> package you've defined, you can do DELETE-PACKAGE, which comes
 >> close to what you want.  This will make those things mostly
 >> subject to the GC, though classes and methods will still be
 >> pointed to by the class system itself, so you really won't get
 >> back all the memory you wanted--but you may get the approximate
 >> effect since you can't (easily) get to those classes any more.

 mg> You can also throw away the classes and methods: * For classes
 mg> you can (setf (find-class 'xxx) nil) (From Ansi CL by Graham) *
 mg> For methods first is (rmove-method generic-function method) * If
 mg> the generic fuction is empty (no more methods): (fmakunbound
 mg> (generic-function-name generic-function)) * All you have to do
 mg> now is to find out all symbols with (apropos-list "") and then
 mg> look for -symbol-value (makunbound ) -symbol-function
 mg> (fmakunbound ) -find-class (setf (find-class ))

My take on this is not to worry about doing it yourself.  It's true
that you can make your application much leaner and meaner by doing so,
but if that's really what you're after, then use the delivery system
provided with your Lisp (if it's commercial one).

For example, LispWorks and ACL both do a good job eliminating unwanted 
symbols (and even whole packages) from the image during delivery.  A
networking, Corba-enabled application on LispWorks, with over 150
screenfulls of implementation code compiles and delivers to a 5 Meg
executable, and during delivery, you can see the symbols which are
eliminated from the final image.

dave