[Prev][Next][Index][Thread]

Re: Destructors



In article <38DC0EB3.CD35C4B9@quiotix.com>,
Jeffrey B. Siegal <jbs@quiotix.com> wrote:
>> Since a C/C++ application has to be
>> able to know when it's appropriate to destroy the application data related
>> to a window, an application written in Lisp/Scheme/Dylan would presumably
>> be given the same opportunity.
>
>On this we will have to reasonably disagree.
>
>Why anyone would want to program in a C/C++ style in Lisp/Dylan is a
>mystery to me.  But you can certianly do it if you want. 
>
>(defun malloc (n) ...)
>(defun free (p) ...)

I'm certainly not advocating that.  But some things have to happen at
specific times, not when GC happens to decide to do them.  For instance,
rather than letting the GC close a file when all references to the stream
have gone away, we have explicit "close" functions.  And when we're
interfacing with external libraries, they often require the caller to
perform explicit actions, and they should be done at the appropriate time.

There are certainly some things that can be left to finalizers, such as
freeing memory, but in many cases you need more explicit control.

-- 
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



References: