Documentation
I'll probably get to this part eventually, if there's sufficient interest. For now you're gonna have to use the source, here's some quick description on where you find what.
Primitive functions
Primitive functions are defined in plain JavaScript,
in js/primitives.js. There's a
function there called defp
— all primitives are defined
through it. That function takes two arguments:
- A boolean which specifies whether the primitive does any side-effects. This is used to optimize away calls to primitive functions when no return value is expected and no side-effects are done.
-
A JavaScript function of two arguments that handles the primitive
operation. The arguments for this one, in turn, are:
m
— a LispMachine object.nargs
— the number of arguments that have been passed to this function.
m.push(...)
.
The arguments are on the machine's stack and can be fetched in reverse
order by calling m.pop()
.
Currently all primitive functions are defined in the base package
(%
) and they're all exported, although many of them should be
kept private. Those that I wasn't sure I'd like to export as they are
have names that start with a funny character like “%”.
Types
In js/types.js we have definitions and supporting functions for various basic types in the system.
List operations
In js/list.js we have defined most operations for linked lists. But from Lisp, of course, you'd access them via primitive functions.
The very basic Lisp system
The first Lisp file that is loaded by the system is
lisp/compiler.lisp and it defines
a bunch of basic functions and macros that are exported, as well as the
reader and the compiler. Stuff defined here is exported
in lisp/init.lisp, which also
implements additional functionality like macros for the package system,
destructuring-bind
, etc.
TinyCLOS
The object system is implemented in lisp/tiny-clos.lisp and it's a straightforward port of TinyCLOS.
FORMAT and printer
There's a pretty comprehensive implementation, though by no means
complete, of the format
function
in lisp/format.lisp. A generic
method (based on TinyCLOS) for printing objects is defined
in lisp/printer.lisp, but there's
no pretty printing for that (any help on implementing that would be
greatly appreciated!).