Garbage (collection, that is...)

Walt Leipold leipold at eplrx7.uucp
Tue May 7 06:23:21 AEST 1991


I've been looking at Scheme as an extension language for some otherwise-
portable code, with particular attention to a pair of public-domain
interpreters named "scm" and "siod" (scm is actually an adaptation of
siod).  While these interpreters are small and complete, their
implementations include a detail that raises my hackles: both of 'em
garbage-collect directly from the C stack and the registers.  Of course,
gc'ing from the stack permits automatic C variables to be used as Scheme
CONS cells, which makes the interpreter *much* simpler.  But my palms
always sweat when I see code that uses #define STACKS_GROW_UP...

The stack is gc'd by saving the address of a main-program automatic
variable, and scanning between there and the address of a current auto
variable for anything that looks like a Scheme pointer.  Registers are
gc'd by calling setjmp() and then examining the register values saved in
the jmp_buf structure.  As a Portability Paranoid(TM), I find this
frightening, since (for instance) I don't think that C is even required
to use a stack to store activation records.

I'm pretty sure that gc'ing off the C stack is non-portable practice. Is
it *good* practice?  In how many current implementations are C activation
records *not* allocated contiguously on a stack?  Should I look elsewhere
for a Scheme interpreter?  (Or am I worrying too much?)

Thanks....

-- 
--------------------------------------------------------------------------
"When dealing with the insane,                                Walt Leipold
it is best to pretend to be sane."              (leipolw%esvax at dupont.com)
--------------------------------------------------------------------------
--
The UUCP Mailer



More information about the Comp.lang.c mailing list