From: upperclass
Subject: unloading functions
Date: 
Message-ID: <1175960105.984352.208430@n59g2000hsh.googlegroups.com>
Hi,

How can I

1) list all functions I have defined so far in lisp ?
2) unload a function/all functions I have defined?

Thank you!

From: Rainer Joswig
Subject: Re: unloading functions
Date: 
Message-ID: <joswig-F96898.18463907042007@news-europe.giganews.com>
In article <························@n59g2000hsh.googlegroups.com>,
 "upperclass" <··········@gmail.com> wrote:

> Hi,
> 
> How can I
> 
> 1) list all functions I have defined so far in lisp ?
> 2) unload a function/all functions I have defined?
> 
> Thank you!

1) See DO-SYMBOLS and FBOUNDP

http://www.lisp.org/HyperSpec/Body/mac_do-symbol_-all-symbols.html#do-symbols
http://www.lisp.org/HyperSpec/Body/fun_fboundp.html#fboundp

2) see FMAKUNBOUND, DELETE-PACKAGE

http://www.lisp.org/HyperSpec/Body/fun_fmakunbound.html#fmakunbound
http://www.lisp.org/HyperSpec/Body/fun_delete-package.html#delete-package

-- 
http://lispm.dyndns.org
From: Slava Akhmechet
Subject: Re: unloading functions
Date: 
Message-ID: <87abxk13ac.fsf@gmail.com>
Rainer Joswig <······@lisp.de> writes:

> 2) see FMAKUNBOUND, DELETE-PACKAGE
Slime also lets you do C-c C-u, which can be very handy.

-- 
Regards,
Slava Akhmechet.
From: Johan Ur Riise
Subject: Re: unloading functions
Date: 
Message-ID: <87abxkdru8.fsf@morr.riise-data.net>
"upperclass" <··········@gmail.com> writes:

> Hi,
> 
> How can I
> 
> 1) list all functions I have defined so far in lisp ?
(let (result) 
  (do-symbols (s)
    (multiple-value-bind (symbol status)
        (find-symbol (symbol-name s))
      (when (and (eql status :internal)
                 (fboundp symbol))
        (push s result))))
  result)


> 2) unload a function/all functions I have defined?

(defun f1 ()...)

(unintern 'f1)
se also other posts
From: Ralf Mattes
Subject: Re: unloading functions
Date: 
Message-ID: <pan.2007.04.09.00.11.03.186972@mh-freiburg.de>
On Sat, 07 Apr 2007 19:20:15 +0200, Johan Ur Riise wrote:

> "upperclass" <··········@gmail.com> writes:

> [...]
>> 2) unload a function/all functions I have defined?
> 
> (defun f1 ()...)
> 
> (unintern 'f1)
> se also other posts

Careful! This will also kill variables named f1 ... fmakunbound will be
better here.

 Cheers, Ralf Mattes
From: Johan Ur Riise
Subject: Re: unloading functions
Date: 
Message-ID: <876485e4u3.fsf@morr.riise-data.net>
Ralf Mattes <··@mh-freiburg.de> writes:

> On Sat, 07 Apr 2007 19:20:15 +0200, Johan Ur Riise wrote:
> 
> > "upperclass" <··········@gmail.com> writes:
> 
> > [...]
> >> 2) unload a function/all functions I have defined?
> > 
> > (defun f1 ()...)
> > 
> > (unintern 'f1)
> > se also other posts
> 
> Careful! This will also kill variables named f1 ... fmakunbound will be
> better here.

Sure.

I use this under development just to make sure that the old name can
not be called. This saves me from some nasty bugs, I believe. A missing
variable is no big deal, and a variable in the global environment
would start with a star anyway.

unintern is shorter, but I just noticed that with name completion,
fmakunbound is unambigous with only two characters (in an otherwise
empty image), while unintern needs four. So I guess I will have to
change my way.
From: Ralf Mattes
Subject: Re: unloading functions
Date: 
Message-ID: <pan.2007.04.09.23.09.35.607303@mh-freiburg.de>
On Mon, 09 Apr 2007 21:16:20 +0200, Johan Ur Riise wrote:

> Ralf Mattes <··@mh-freiburg.de> writes:
> 
>> On Sat, 07 Apr 2007 19:20:15 +0200, Johan Ur Riise wrote:
>> 
>> > "upperclass" <··········@gmail.com> writes:
>> 
>> > [...]
>> >> 2) unload a function/all functions I have defined?
>> > 
>> > (defun f1 ()...)
>> > 
>> > (unintern 'f1)
>> > se also other posts
>> 
>> Careful! This will also kill variables named f1 ... fmakunbound will be
>> better here.
> 
> Sure.
> 
> I use this under development just to make sure that the old name can
> not be called. This saves me from some nasty bugs, I believe. A missing
> variable is no big deal, and a variable in the global environment
> would start with a star anyway.
> 

Hi Johan,

I hope this doesn't sound to picky, but unintern will do much more than
remove variable  bindings. I basically removes a symbol from a package -
the next time the reader encounters this symbol it will intern a new one. 
Symbols are used for muc more than naming global variables and functions -
think of class & slot names, property lists, assocs, hash table keys ...
And of course both fmakunbound and unintern won't really do what the OP
asked for - "unload" a function .... ;-)

 Cheers, RalfD

> unintern is shorter, but I just noticed that with name completion,
> fmakunbound is unambigous with only two characters (in an otherwise
> empty image), while unintern needs four. So I guess I will have to
> change my way.
From: Johan Ur Riise
Subject: Re: unloading functions
Date: 
Message-ID: <871wisef8k.fsf@morr.riise-data.net>
Ralf Mattes <··@mh-freiburg.de> writes:

> 
> Hi Johan,
> 
> I hope this doesn't sound to picky, but unintern will do much more than
> remove variable  bindings. I basically removes a symbol from a package -
> the next time the reader encounters this symbol it will intern a new one. 
> Symbols are used for muc more than naming global variables and functions -
> think of class & slot names, property lists, assocs, hash table keys ...
> And of course both fmakunbound and unintern won't really do what the OP
> asked for - "unload" a function .... ;-)
> 

No problem. The function does not go away unless the symbol is the only
variable name bound to the function. Uninterning a symbol and then interning
it, is equvalent to fmakunbound + makunbound + removing the property list.
From: Steven Haflich
Subject: Re: unloading functions
Date: 
Message-ID: <8gWRh.873$2v1.537@newssvr14.news.prodigy.net>
upperclass wrote:

> How can I
> 
> 1) list all functions I have defined so far in lisp ?
> 2) unload a function/all functions I have defined?

This is not a very well-formed question within the context of
Common Lisp.  It presupposes some meaning to "define" and "undefine
a function".  Informally hese may mean something, but those meanings
probably assume things in the language semantics.

The most useful answer to your question is probably this: Restart
your Lisp session.  But that isn't keeping with the spirit in
which you asked the question.  So here's a hint how to rethink the
question:

A lisp defining like defun does two things.  It creates a function,
which is a first-class object in Common Lisp, and it also binds
that function to the function definition of the name that is the
first subform of the defun  form.

Once an object is created in Common Lisp, there is no way to uncreate
it.  (Except that if you drop all references to the object, the gc
reclaim its space, and even if not, there is no way for it to affect
you any longer.)  But it is possible to undo or replace the binding
between certain names and that object.  Consider which you want to do.

(Pascal's answer addresses the latter, and correctly, but the question
itself is one Lispers essentialy never ask, so the fact that you are
asking it should be more interesting to you than the answer...)