diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-08-21 14:54:57 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-08-21 14:55:54 +0100 |
commit | 0f68afd9a040256939ddd082a380bd37b0a3996b (patch) | |
tree | 2c59292ca62bfe70a09b7e7efadfcc756b0914c6 /sys.c | |
parent | 742f19886cce986d0d01606b07dd533fbffe2cdd (diff) | |
download | alisp-0f68afd9a040256939ddd082a380bd37b0a3996b.tar.gz alisp-0f68afd9a040256939ddd082a380bd37b0a3996b.tar.bz2 alisp-0f68afd9a040256939ddd082a380bd37b0a3996b.zip |
Make nicer primitive functions for car/cdr
If it isn't a CONS, we return NIL instead of failing. This way, we
can use it in our general iteration functions. Eventually the actual
runtime would use this as well. The macros are mostly for internal
use to do assignment etc.
Diffstat (limited to 'sys.c')
-rw-r--r-- | sys.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -43,12 +43,13 @@ void sys_cleanup(sys_t *sys) return; // Iterate through each element of memory - for (lisp_t *cell = sys->memory, *next = CDR(cell); cell; - cell = next, next = CDR(cell)) + for (lisp_t *cell = sys->memory, *next = cdr(cell); cell; + cell = next, next = cdr(next)) { // Only reason allocated exists is because we had to allocate memory on the - // heap for it. It's therefore - lisp_t *allocated = CAR(cell); + // heap for it. It's therefore enough to deal with only the allocated + // types. + lisp_t *allocated = car(cell); switch (get_tag(allocated)) { case TAG_CONS: |