3 ms·
In C you can create a higher level language with an absolutely air-tight, precisely tracing garbage collector that is free of issues like false retention. You
by aidenn0 12y ago
In C you can create a higher level language with an absolutely air-tight, precisely tracing garbage collector that is free of issues like false retention.
You can do it portably if you just don't store objects on the C stack, and you can do it non-portably if you do so.
- kazinator 12y ago> In C you can create a higher level language with an absolutely air-tight, precisely tracing garbage collector that is free of issues like false retention. If so, you will be the first; I look forward to the "Show HN:" when it's done. > You can do it portably if you just don't store objects on the C stack, Sure, for example, you can do it portably in C if you write a complete emulator for an 80386, and then use that to run an assembly language program. That program isn't a utility for your C code; it's not extending the host C with a garbage collector or whatever else. If you do not store object references on the stack, your use of C is severely crippled to the point that it's not really C any more. For one thing, C function arguments are on the stack (or, more abstractly, "automatic storage"), so say goodbye to conventional use of C argument passing: the backbone of most normal C programming. That garbage collector isn't for C. C has automatic storage, and a proper garbage collector has to traverse it. > and you can do it non-portably if you do so. Sure, if non-portably means going as far as forking a specific C compiler with your custom hacks, and requiring that C compiler, or else living with the imprecision and taking a whack-a-mole approach to plugging the issues as they arise.
- aidenn0 12y agoChicken scheme uses C function calls, and merely requires a contiguous stack for automatic storage (which is technically non-portable, but doesn't require forking a compiler): http://en.wikipedia.org/wiki/CHICKEN_%28Scheme_implementation%29 http://en.wikipedia.org/wiki/CHICKEN_%28Scheme_implementatio... [edit] And here is a toy scheme interpreter that uses precise garbage collection to show off the Ravenbrook MPS http://www.ravenbrook.com/project/mps/master/manual/html/guide/lang.html#the-scheme-interpreter http://www.ravenbrook.com/project/mps/master/manual/html/gui...