Make a Lisp [4] Technical SITREP

21 Apr 2019

This is the fourth SITREP for my ongoing Make-a-Lisp project - a multi-step process that involves implementing JKL: a Lisp interpreter capable, in theory, of self-hosting. Prior posts include Background, Steps 0-4 and Steps 5-8.

Summary

Step 9 is the penultimate step, and adds exception handling and two new core functions: map and apply. It’s good to be back on track after the painfully slow progress of Step 8.

The source code is on Github.

Step 9

The JKL REPL handles errors (such as a call to an undefined function) that occur during reading or evaluation using a C# try...throw...catch... mechanism. Without such a mechanism, errors would potentially crash JKL. Step 9 makes a similar mechanism available to hosted Lisp code, so that user-defined functions can themselves raise errors without stopping the overall program and dropping back to the underlying JKL REPL. Error handling was very quick to implement (two evenings), given that the JKL mechanisms are really just wrappers around the underlying C# equivalents. Pleasingly, the approach I used integrated cleanly with the TCO loop inside EVAL (from step 5).

apply and map were also both very quick (an hour or so for coding and running tests) with no significant problems to overcome. I initially used EVAL internally to each to apply the function, but then realised that the Apply method associated with JKL functions is there for precisely this reason, so redid them both properly.

At this point, I’m almost ready for the last step, which is different from all the prior steps - as will be described in the next post in this series.