Re: deleting a class

Ralf Juengling <[email protected]>
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
On Fri, 2005-04-08 at 12:52, Raymond Martin wrote:
> Of course you cannot delete a class. A class is a declaration that is
> used to instantiate objects. You delete objects, not classes.

Yes. My posting wasn't very clear. My point was that you probably
never want to redefine a class either and therefore want to get
an error if you try to do so--just as when you try to delete a class.


On Fri, 2005-04-08 at 17:23, Leon Bottou wrote: 
> > But then it should 
> > not be allowed to redefine a class either: 
> 
> Redefining means creating a new class with the same name.
> If there were instances of the old class, these instances remain
> associated with the old class.  You can still access the old class ]
> using the <classof> function. 


? (defclass |A| object
       (version "1"))
= |A|
? (defmethod |A| print-version ()
      print version)
= print-version
? (setq a1 (new |A|))
= ::A:978aa80
? (==> a1 print-version)
= "1"
? (defclass |A| object)
= |A|
? (defmethod |A| print-version ()
      print "2")
= print-version
? (==> a1 print-version)
= "1"
? (setq a2 (new |A|))
= ::A:9d4f770
? (==> a2 print-version)
= "2"
? (setq another1 (new (classof a1)))
= ::A:9d4b360
? (==> another1 print-version)
= "1"
?

Makes sense, thanks.


>  When no instances of the old class remain,
> the old class is simply garbage collected.
> 
> Try this:
> ? (pretty (macro-expand (defclass foo object)))

cool.

ralf





-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.