Eloquent is a reference implementation of 233-Lisp, which is a personal dialect of Lisp.
Write your code and save them into a file, assume the file name is script.scm, you can load this file as following
./test_repl -l script.scm
- libgc-dev
- libgmp-dev
make test_compiler
make test_vm
make test_repl
Define the new primitive function in file prims.c, and put its declaration into the header file prims.h. The data type of the formal parameters and return value of this new function must be struct lisp_object_t *, which also named lt * by typedef.
Register this new function into the implementation's global environment. In the body of function init_prims, use the predefined macro ADD for installing. Macro ADD has four parameters, their meaning list as follow:
- arity. It's the total number of parameters of a primitive function. The rest parameter, for example, the parameter y in form (x . y) is also counted. Therefor, parameters list (x . y) means arity of 2.
- restp. A flag indicates whether the function accepts variable number of parameters or not.
- function_name. The name of the function been defined.
- Lisp_name. It's a C string, used to be the function name in the Lisp code.
The new primitive function is invokable in the Lisp code level.