Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!bruce!trlluna!ait!greg From: greg@ait.trl.oz (Greg Aumann) Newsgroups: comp.lang.eiffel Subject: Re: What happens when you're gone and forgotten? Message-ID: <1200@trlluna.trl.oz> Date: 20 Mar 90 05:41:00 GMT References: <1586@xyzzy.UUCP> Sender: root@trlluna.trl.oz Lines: 24 From article <1586@xyzzy.UUCP>, by langley@yoyodyne.rtp.dg.com: > > How do I write a class so that a routine will get called > every time the object is forgotten? > > I ask "how do you define a destructor?" Is it the case that > for some reason this sort of functionality isn't useful in Eiffel? I would very much like to have this sort of facility available for an application that I am writing. The application is written in Eiffel and C and uses X windows. There are two reasons that I would like to have a destructor function. One is to free memory that was malloc'ed in the C part of the application but is linked to an Eiffel object. The second is to free X resources in the X server which are also similarly linked to an Eiffel object. What I would like to be able to do is to write a destructor which simply frees the non-Eiffel resources when the corresponging Eiffel object is destroyed. I realise that such a facility can be dangerous but I think it is better to have it than to try and free stuff explicitly (which is why there is a GC in the first place). ------------------------------------------------------------------------- Artificial Intelligence Systems ACSnet: greg@trlamct.trl.oz Telecom Research Laboratories Internet: greg@trlamct.trl.oz.au Melbourne, AUSTRALIA Voice: +61 3 541 6222