Update on compiler

I’ve now got an almost Turing complete interpreter now. It can evaluate maths expressions, do conditionals, loops, set variables, create functions and (not completely working) define macros! I rewrote the entire project in C because the construct/destruct pattern got in my way more times than it helped with cleaner code. I’ve also done reworks on how data is associated with objects: the vast majority of data will be a pointer that exists outside of the object and the object acts as a wrapper over this. Lists, vectors, tables are direct structures inside objects, but their internal data is just pointers to actual data so it’s easy to create wrappers for other lists.

I think my greatest achievement is the reference counting pseudo garbage collector. First I separated the standard object freeing function into a ‘wrapper’ clean and a ‘recursive’ clean, in relation to the previous point of data being pointers. Secondly each object has a byte representing the number of references to the object; on some data structure append or construction of other data types based on an object, that object gains a reference. The upshot: any freeing action stops if the object it’s freeing has a count greater than 0. This stops data that still has references dangling about from being invalidated. Before any recursive data clean on greater types, references are decreased for valid reference counts. Environments (which manage variables) increase references on value data so the vast majority of times most cleans of data before the environment clean will be unable to fully clean data.

I’ve now got to write an interpreter for inductive data structures and proof/claim statements.