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

Is there a macro (with-no-gc...) Should there be?



 >To: info-mcl@ministry.cambridge.apple.com
 >Newsgroups: comp.lang.lisp.mcl
 >From: bc@wetware.com (monsieur HAINEUX)
 >Subject: Is there a macro (with-no-gc...) Should there be?
 >Sender: news@wetware.com (Usenet News Account)
 >Nntp-Posting-Host: wetware.wetware.com
 >Organization: Castle Wetware
 >Date: Sat, 27 Nov 1993 19:26:40 GMT
 >
 >The idea seems appealing to me, a Lisp-like "take a deep breath and..."
 >
 >bill coderre
 >happy shopping season

There's no (with-no-gc ...) form, because you can trigger a GC
by asking for new storage, also called "consing". Functions like
CONS, LIST, APPEND, MAKE-ARRAY, and MAKE-INSTANCE, and any
function which calls one of these, will "cons", or request new
storage. The real trick is learning all the different ways
MCL might try to allocate new storage.

The garbage collector will not be invoked if you do not request
new storage. So, instead of writing a with-no-gc form, just write
an ordinary expression. Avoid allocating new storage in the critical 
section of code by preallocating everything your algorithm needs
before entering it.