Thread View: comp.lang.clos
4 messages
4 total messages
Started by PeiYu Huang
Mon, 12 Oct 1992 22:35
How to neatly destroy instances?
Author: PeiYu Huang
Date: Mon, 12 Oct 1992 22:35
Date: Mon, 12 Oct 1992 22:35
10 lines
706 bytes
706 bytes
Well, by "neatly" I mean something other than:
cl>(setq my-instance (make-instance 'MY-CLASS))
#<MY-CLASS @ .......)
cl>(setq my-instance NIL)
All suggestions are welcome. Thanks in advance..
P. Huang
Re: How to neatly destroy instances?
Author: Thomas A. Russ
Date: Tue, 13 Oct 1992 00:24
Date: Tue, 13 Oct 1992 00:24
28 lines
1400 bytes
1400 bytes
In article <...> huangp@wasser.Colorado.EDU (PeiYu Huang) writes: > Well, by "neatly" I mean something other than: > > cl>(setq my-instance (make-instance 'MY-CLASS)) > #<MY-CLASS @ .......) > > cl>(setq my-instance NIL) > > All suggestions are welcome. Thanks in advance.. > If you don't use global (special) variables, then you don't need to do anything to eliminate unused instances. One simple solution would be: (let ((my-instance (make-instance 'MY-CLASS))) ....) After the let form, my-instance is not bound and the instance of MY-CLASS that was created is freed for the garbage collector. Why do you feel a need to destroy instances explicitly? -- Thomas A. Russ tar@isi.edu USC/ISI, 4676 Admiralty Way, Marina del Rey, CA 90292 (310) 822-1511
Re: How to neatly destroy instances?
Author: PeiYu Huang
Date: Tue, 13 Oct 1992 14:20
Date: Tue, 13 Oct 1992 14:20
12 lines
1118 bytes
1118 bytes
In article <22625@venera.isi.edu>, tar@ISI.EDU (Thomas A. Russ) writes:
>
>Why do you feel a need to destroy instances explicitly?
>
Because I use a class variable list to maintain all current instances
of that class for browsing purpose. One can use a form in an "initialize-instance :after" method to update the list. I guess I may need to define another method to
clean up the list BEFORE destroying the instance, say my-instance, otherwise when
my-instance becomes unbound, I can no longer access the list via it.
Any comments?
P. Huang
Re: How to neatly destroy instances?
Author: Tim Larkin
Date: Tue, 13 Oct 1992 16:37
Date: Tue, 13 Oct 1992 16:37
26 lines
1554 bytes
1554 bytes
In article <1992Oct13.142031.569@colorado.edu> PeiYu Huang, huangp@wasser.Colorado.EDU writes: > Because I use a class variable list to maintain all current instances >of that class for browsing purpose. One can use a form in an >"initialize-instance :after" method to update the list. I guess I may need to >define another method to >clean up the list BEFORE destroying the instance, say my-instance, otherwise when >my-instance becomes unbound, I can no longer access the list via it. I may be missing something here, but if the instance belongs to the class variable list, and neither belongs to any other set nor is the value of any global symbol, then to "destroy" it, by which I infer you mean to recover its allocated memory, you need only to remove it from the class list. The gc will then recover the memory. I guess I'm not too certain what you mean by "destroy". Tim Larkin Federal Nutrition Laboratory Tower Road Ithaca, New York tsl1@cornell.edu 607-255-7008
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads