skp@stl.stc.co.uk (Steve Perryman ) (08/09/90)
Is there a standard destructor function in Common Lisp or CLOS ??? There is no mention of one in Sonya Keene's book on CLOS, but is there one/ going to be one (in current standards etc) ?? I have crashed my application cos it creates reams of temporary objects that need to be destroyed after their use, and the garbage collector cannot handle it. My lisp system has a destructor function but it is definitely non-standard and I want to use something more standard if possible. Thanks in advance, Steven Perryman (skp@stl.stc.co.uk)
dsr@luke.mitre.org (Douglas S. Rand) (08/10/90)
In article <3296@stl.stc.co.uk>, skp@stl.stc.co.uk (Steve Perryman ) writes: |> |>Is there a standard destructor function in Common Lisp or CLOS ??? |>There is no mention of one in Sonya Keene's book on CLOS, but is there one/ |>going to be one (in current standards etc) ?? |> Although this might be useful this is not a goal of CLOS. Also it is generally antithetical to the view of the LISP world. It is the job of the GC to clean up allocated unused storage. |> |>I have crashed my application cos it creates reams of temporary objects that |>need to be destroyed after their use, and the garbage collector cannot |>handle it. My lisp system has a destructor function but it is definitely |>non-standard and I want to use something more standard if possible. |> A possible work around to your problem is to add a personal destructor function whose job it is to place an object back on a reuse heap. You obviously need to be careful that the object really isn't in use (this is why GC is hard to write). There is a generic function reinitialize-instance which might or might not help you with cleaning the old objects. But in any case you then need to modify make-instance (allocate-instance?) for that class to grab objects off the heap before allocating a new one. |> |>Thanks in advance, |> |>Steven Perryman |>(skp@stl.stc.co.uk) Douglas S. Rand Internet: <dsrand@mitre.org> Snail: MITRE, Burlington Road, Bedford, MA Disclaimer: MITRE might agree with me - then again... Amateur Radio: KC1KJ
aarons@syma.sussex.ac.uk (Aaron Sloman) (08/12/90)
skp@stl.stc.co.uk (Steve Perryman ) writes: > Date: 9 Aug 90 07:46:25 GMT > Organization: STC Technology Limited, London Road, Harlow, Essex, UK > > Is there a standard destructor function in Common Lisp or CLOS ??? > There is no mention of one in Sonya Keene's book on CLOS, but is there one/ > going to be one (in current standards etc) ?? > > I have crashed my application cos it creates reams of temporary objects that > need to be destroyed after their use, and the garbage collector cannot > handle it. My lisp system has a destructor function but it is definitely > non-standard and I want to use something more standard if possible. > > Thanks in advance, > > Steven Perryman > (skp@stl.stc.co.uk) For information, Poplog (since V13.6) introduced the concept of a destroy_action. These are implemented via an extension to the property mechanism. Here is an extract from the online "REF PROPS" file: ------------------------------------------------------------------- Destroy properties thus allow arbitrary procedures to be attached to objects in such a way that the procedure gets run, with the object as argument, at the point at which the object would otherwise have become garbage (the point of its destruction). ------------------------------------------------------------------- This mechanism is available for all the Poplog languages (Common Lisp, Pop-11, Prolog, ML) via the Pop-11 interface. For example it allows you to ensure that if certain program items have windows or icons on the screen associated with them, then those screen objects are automatically removed if ever the program items become garbage. Aaron Sloman, School of Cognitive and Computing Sciences, Univ of Sussex, Brighton, BN1 9QH, England EMAIL aarons@cogs.sussex.ac.uk or: aarons%uk.ac.sussex.cogs@nsfnet-relay.ac.uk
rpk@wheaties.ai.mit.edu (Robert Krajewski) (08/13/90)
In article <116718@linus.mitre.org> dsr@luke.mitre.org (Douglas S. Rand) writes: Although this [destructors] might be useful this is not a goal of CLOS. Also it is generally antithetical to the view of the LISP world. It is the job of the GC to clean >up allocated unused storage. Yes, but since the one of the breat benefits of Lisp is that you don't have to write your own garbage collector, it would be nice to extend it in ways that CLOS can exploit. For example, an object may hold onto something that is outside the Lisp universe, like some kind of operating system resource. There is no way for the GC to reclaim it, but it *could* ask the object to do so. It's pretty clear that this kind of extension can be fraught with peril (for example, the reclamation method better not store its object into anything except lexical places that cannot have a lifetime beyond the execution of the method itself), but it could be useful. -- Robert P. Krajewski Internet: rpk@ai.mit.edu ; Lotus: robert_krajewski.lotus@crd.dnet.lotus.com
dsr@luke.mitre.org (Douglas S. Rand) (08/13/90)
In article <9862@rice-chex.ai.mit.edu>, rpk@wheaties.ai.mit.edu (Robert Krajewski) writes: |>Yes, but since the one of the breat benefits of Lisp is that you don't |>have to write your own garbage collector, it would be nice to extend |>it in ways that CLOS can exploit. |> |> ... Many reasons for it being a breat bennefit I wasn't really passing judgement on the value. Certainly it would be nice to know that you (the object) were about to be blown away so your resources could be handled in a reasonable fashion. I was just commenting on it not being a goal of CLOS or ANSI-X3J13. Douglas S. Rand Internet: <dsrand@mitre.org> Snail: MITRE, Burlington Road, Bedford, MA Disclaimer: MITRE might agree with me - then again... Amateur Radio: KC1KJ