This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> There was some talk a while back about why precise GC was too hard > in a C environment. I thought I might show people how I did it in a > little scheme I wrote a while back. It's pretty simple and pretty > easy to use, but I'll let people more expert comment on it. You > _don't_ have to use a special macro to assign objects around. > > In a header file I put these definitions... > #define s_beginGcArea() int s_gcStackPos = s_gcContext.cStack.pos > #define s_prepGc(v) pushStackAutoResize(&s_gcContext.cStack, &(v)) > #define s_defGc(type, name, init) type name = (type)(s_prepGc(name), init) > #define s_endGcArea() popStackTo(&s_gcContext.cStack, s_gcStackPos) This is basically what Emacs does. I found that we frequently forgot to do the equivalent of s_defGc when it was necessary. In your example, it's easy to see that rtn->length is protected, since rtn is protected, but when the function is doing something more complicated (walking and editing a tree), it got harder. Don't get me wrong --- it feels nice and simple to me, too. But it is a fact that I made a lot of mistakes. Stallman did too.