hi David,
It was amazing to run such high-level language such as lisp in atmega328.
But sad to see only 320 objects in ram at a time.
http://www.ulisp.com/show?1BLW
I wonder if a variable width scheme for object representation could save some bytes.
Lets assume Symbol and Number objects will only appear inside a List object. Global variables can be put inside a list to achieve this. This assumption essentially reduces size of Symbol and Number objects to 2 bytes + some bits. I am not sure if a single variable could be part of multiple lists and invalidate this assumption.
The list object will still be 4 bytes. But car will represent the object directly if its a Symbol or Number, and a pointer if its another List. Some additional bit needs to be used to represent the type of object(Symbol, Number, List) car points to.
Does it make sense.
I do not know of the detailed implementation. So I may be missing some important details.
There are other alternate techniques that could save further. For example,
- Number object can be split into 2 type based on their size (one byte or two byte). Since one byte numbers are quite common in arduino, this could save a lot.
- Symbol object could represent the index into the symbol table and be one byte, instead of the radix40 function name it contains.
- List object can be better represented instead of car, cdr. For each additional entry in the list, it wastes/uses one cdr pointer. If one list item could contain multiple car pointers, it could be better.
Let me know. Thanks