pure_LISP reference manual

SECD: [ index ] [ collection ] [ hard_SECK reference ]
LISP: [ reference ] [ tutorial ] [ implementation scheme ]

This document describes pure_LISP language, implemented on an modified SECD machine.

Use also the Tutorial - it provides some info about installation and first steps in the package.

1. Data types, syntax, functions.

Data types in pure_LISP:

Terminal data types:

Composite data types:

Integer 0  is used for true logical value, while 1 represents false. Atom nil is the same as () and represents empty list.

Syntax is as simple as possible:

The only special symbols are ( ) . SPACE. CR and LF are treated as SPACE.

Lexeme is a sequence of non-special symbols.

Hello 234 -128 a b nil #ld_0_1
are proper lexemes.

Expressions are:

Functions in pure_LISP:

Both data and programs in pure_LISP are represented by the expressions !

The program is simply a function call. Each function call have the form:

(function arg1 arg2 ... argn)

A function may be defined by the compiler (main function) or by the user. The main function lambda defines new user functions. The process of program execution in LISP is called evaluation.

Evaluations in pure_LISP are lazy (non-strict or call-by-need designations are used). Shortly in lazy evaluation model the evaluation process return formulas for more complex expressions, instead of values. The actual evaluation is done only if access to some details of the complex expression is needed.

This model allows programming with infinite data structures and defining user functions, receiving semi-correct parameters,  for example:

(letrec ...
(or lambda(e1 e2)
(if e1 0 e2))
In strict evaluation model usage of above-mentioned user defined function or will cause an error in expression (or (eq l nil) (eq (car l) 0)) if l is an empty list, while in lazy evaluations e2 will not be evaluated at all.

The rules for lazy evaluations are defined in the compiler.lib source.

Shortly, evaluation of the parameters of all user functions are delayed, the parameters of main function cons are delayed as well.

First parameter of if and all parameters of all main primitives except cons are forced. The evaluation of the body of user function is forced. let and letrec are treated as user functions.

2. Main functions (functions, defined by the compiler).

Primitive functions:

Arithmetic functions:

Predicate functions: List/atom functions: Other primitives:

All primitive functions have their correspoding code in SECD architecture. They all have 1 or 2 parameters. Except cons, all are compiled to force evaluation of their parameters. Cons delay the evaluation of the parameters.

The other group of main functions may be called special functions (for control, i/o, process control and other purpouses). They all have specific semantics.

Special functions:

Functions, defined by the compiler are accesible from all programs.

If your program will work alone (not in miniOS shell) it must use only these functions and functions, defined in the program !

3. Run Time Library (RTL) functions and variables.

If you use miniOS, some additional functions and variables are accesible.
They are defined in run time library and are writen in pure_LISP.
RTL consists of many sources - system.lib, btree.lib, sysfun.lst, errors.lst, compiler.lib and miniOS.lsp.

Variables input and output are defined in miniOS to represent standard input and output stream for current shell account.
Variable syspipe is used to organise breakable compilation, allowing syntax error handling by the compiler.
It is used in the same maner for runtime error handling.

Functions in system.lib:

File sysfun.lst contains a list of records, representing some info about the compiler functions.
The fields in the file have the following semantics:

File errors.lst contains a list of sentences, giving some info about the run time errors.

Functions in btree.lib are part of the compiler, but some of them are useful utilities:

Functions in compiler.lib:

Functions in miniOS.lsp:

(c) Skelet, Sep 2002 in terms of GNU GPL

Mail me at home or work