Newsgroups: comp.lang.scheme Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: gyro@cymbal.reasoning.COM (Scott Layson Burson) Subject: Ports & GC Message-ID: <9104291751.AA10911@cymbal.reasoning.com.> Sender: daemon@athena.mit.edu (Mr Background) Reply-To: Gyro@reasoning.com Organization: The Internet References: <480@data.UUCP> Date: 29 Apr 91 17:51:47 GMT Lines: 29 Date: 26 Apr 91 15:40:30 GMT From: Ken Dickey [Answering a question about whether garbage ports are closed automatically] Implement finalization objects. I did this in a local copy of the Gambit runtime (v1.5) by implementing weak-pairs (the car goes to nil when collected). The finalization procedure registers each object to be finalized with a thunk which does the cleanup. The object is in the car of a weak pair, the thunk in the cdr. After a collection, the weak-pairs are scanned and any who's car is nil is thrown away after the finalization thunk is invoked. {The rules are that such a thunk does not cons and does not invoke random continuations.} A finalization service is also helpful for freeing storage for dumb allocators like C's malloc. Weaks/populations, etc. are helpful in a variety of ways. Somebody on this list recently alluded to "the well-known difficulty of defining UNWIND-PROTECT in the presence of firstclass continuations". I have long thought that what UNWIND-PROTECT ought to mean is that the cleanup actions are performed when the continuation in which they were established becomes garbage. As Ken points out, this really isn't all that hard to implement. -- Scott Gyro@Reasoning.COM