2 ms·
So "cons", and the associated "car" and "cdr" functions are innately the "thing" that needs to be garbage collected in Lisp-like languages. So I immediately we
by dragontamer 5y ago
So "cons", and the associated "car" and "cdr" functions are innately the "thing" that needs to be garbage collected in Lisp-like languages.
So I immediately went to the manual, and CTRL+F'd for cons. Carp has the following restriction: https://github.com/carp-lang/Carp/blob/master/docs/Manual.md https://github.com/carp-lang/Carp/blob/master/docs/Manual.md
> If you're calling a dynamic function (something defined with defndynamic, or a built in command) it will be executed right away. This works very much like a classic, dynamically typed Lisp interpreter. The dynamic functions are not available in compiled code! Their main usage is in macros and to programatically control your build settings.
cons, car, and cdr are all "Dynamic" functions that can only run _DURING COMPILE TIME_. Which means the GC is not needed during runtime: all garbage-collection occurs in the compiler.
- kazinator 5y agoThat's a Lisp preprocessor for a non-Lisp language. If you program in C using the Common Lisp c-mera preprocessor, or any of the other similar systems, it's the same thing. You're writing everything in S-exps, and the expansions use conses, but the output is C; so that of course that cannot call cons at run time. https://github.com/kiselgra/c-mera https://github.com/kiselgra/c-mera