CSX

C with S-Expressions

That’s my bachelor thesis, a new method of embedding Lisp into C by providing a library which supports writing Lisp-like expressions directly as C expressions.

I think it is an interesting example of how even a language which is considered to be restrictive can turn out to be flexible enough to mimic such a permissive language as LISP.

The source code is available on GitHub. You can read the thesis here, although it is available only in Russian.

In short, all LISP objects are represented as fat pointers in void*, and vararg functions are used to implement the list notations of LISP. 0 is used as an end marker for the list notations, since all objects are pointers and no valid pointer can be 0. The library enables writting code like this, intermixing C and LISP-style code:

printf("%d\n", *(int *)E(L(S("+"), I(37), I(73), 0)));

Here E stands for eval, L for list, S for symbol, and I for integer.