This document describes the installation and introduction to the package
SECD_Mania, especially the final part of the package
- pure_LISP language and its implementation
base - the virtual SECD machine.
pure_LISP is a pure LISP implementation for GNU/Linux OS,
based on an modified version of SECD virtual machine.
"Pure" means, that the language is functional as possible:
- there is no obvious assignment construction
- only input/output functions may cause side effects and
IO objects (files, connections, pipes) may changes during evaluation.
- the only program control constructions are:
- conditional evaluations
- recursive function calls
- non-deterministick calls and fails,
completed with interprocess message passing.
The language have the following properties:
The properties, omited in the language:
- it is a statically scoped and properly tail-recursive dialect of LISP.
- it is non-strict language (or language with lazy evaluations).
- it supports:
internal multitasking and timesharing
asynchronous file and TCP connection handling
interprocess message passing mechanism.
- wide range of data types (only atoms and integers are terminal types now).
- atom space is not indexed and garbage collector doesn't work on it.
- links to other languages and OS libraries.
Download the pure_LISP from here.
You must have FreePascal
installed on your system.
If you use Debian Linux, simply type:
apt-get install fp-compiler binutils
If you use some other Linux, go to FreePascal home page for instructions.
There is some troubles with the new versions of Free Pascal (Version 1.9.x and higher).
One of the meta files (sec_drivers.pp) uses the Linux unit.
This unit must be replaced with the new units Unix and BaseUnix in future versions,
but now (October 2004) i use the unit OldLinux instead of Linux to resolve current dependencies.
This change is made only in sub-package Base_4.
Download the package in some new directory (i prefer 'secd'), then type:
tar xzf LISP_0.8.tar.gz
Now you have the package sources in subdirectory Base_4.
After this, SECD virtual machine will be compiled and started. (read
the make_all shell script for details).
The bootstrap process is simple - first the strict_LISP program kernel.sec
is loaded and started.
Kernel, together with SECD machine emulates multitasking system.
The first task loaded and executed is the SECD code from the file miniOS.sec.
This code defines a small miniOS
The following lines appear on the console:
Loading /home/YourAccount/secd/Base_4/kernel.sec ...
Executing kernel ...
Loading miniOS ........ Done
Now type at the prompt:
(add 2 5)
miniOS will respond to you:
SEC>(add 2 5)
The first line of the response - list (#ldc 2 #ldc 5 #add) is a SECD code, compiled version of your command (add
2 5). This code is then executed and the result - integer number 7 in this
examle is printed on the conslole.
(#ldc 2 #ldc 5 #add)
Try a more complex expression:
SEC>(let (mul a a) (a add 2 3))
The above expression is a pure_LISP record for the mathematical notation:
(#ldc 2 #ldc 3 #add)
#trlet_1 #ld_0_0 #rec #ld_0_0 #trrec_mul)
Let a is the sum of 2 and 3.
Evaluate a multiplied by a and give the result.
More info about possible pure_LISP functions you may find in pure_LISP reference.
3. Files in the package.
Open a new console and go to the pure_LISP package subdirectory (in
my computer this is /home/skelet/secd/Base_4).
Computer will show you the package files and subdirectories.
These files may be arranged in some different groups:
- secd is the main program of the package - SECD virtual
Usage: ./secd [code_name]
Example: ./secd miniOS
will execute the secd code from the file 'miniOS.sec'.
For more detailed explanation of SECD bootstrap process see
meta is a subdirectory, containing pascal sources,
defining SECD machine:
- secd.pp is the main program
- sec_lists.pp defines SECD data types,
list meta commands and garbage collectors.
- sec_codes.pp defines the SECD machine interpreter.
- sec_atoms.pp defines the atom space and lexeme handling.
- sec_drivers.pp defines file and TCP handling.
- make_all is a shell script. It compiles and runs the SECD
- Changes.txt describes differences from the previos machine
(in bigger package SECD Mania).
- *.lst files contains some data:
- sysfun.lst is a list of the names and associated info for
compiler defined pure_LISP functions.
- krn_fun.lst is a list of the names and associated info for
compiler defined strict_LISP functions.
- errors.lst is a list of sentences about run time errors.
- secd.log is log file, where the working SECD machine will
write some statistics and error messages.
- kernel.sys is the source of the strict_LISP kernel.
See implementation for more info.
- *.lsp and *.lib files are pure_LISP sources for
programs and libraries:
- miniOS.lsp is the main part of the miniOS. It uses the
libs system, btree and compiler.
- client.lsp is a simple client who talks with the miniOS
using TCP connection.
- strict.lsp is a strict_LISP compiler. It is used for
compilation of the kernel only.
- system.lib is a library for the basic I/O and other functions.
- btree.lib is a library for some binary tree utilities,
used by the compiler.
- compiler.lib is a library containing the compiler sources.
- numbers.lib is a library for all numeric examples.
- sysmono.lib is old version of system.lib, used by non-deterministic
- *.sec files are pure_LISP program codes (SECD codes):
- miniOS.sec is the code of the miniOS server.
- client.sec is program code for miniOS client.
- kernel.sec is the kernel code.
- cli_0, cli_1 subdirectories are created with only purpose
to hold the 'secd.log' file for other started copies of the secd program.
I use them to start new client connections to the miniOS server. First
I open new Linux console, then:
After this, new miniOS shell console is started. All works are done by
the miniOS server (miniOS.sec code). Program client.sec is only mediator
between new console and the server.
- html subdirectory contains documentation for pure_LISP:
- In Numbers subdirectory are defined some infinite sequences
from the theory of numbers.
- Examples subdirectory contains other examples.
4. pure_LISP examples.
For the most of the examples the following procedure must be used to start
- first copy the example source from its directory (Numbers or Examples)
into the main directory.
This must be done in Linux shell:
cp example_dir/example_name.lsp .
- compile the example in SEC shell:
(comp_lsp (quote example_name))
- execute the example:
(exec (quote example_name))
Examples in subdirectory Numbers demonstrate the usage of infinite
sequences in lazy evaluations. They all uses the library numbers.lib. In
this library are defined lists of all numbers, prime numbers and pitagorean
triples. But in final expression only limited part of these lists may be
evaluated and printed (if we try to print all numbers, some overflow will
- fiblist prints first 30 Fibonachy numbers.
- pitlazy prints first 100 Pitagorean triples.
- pitfast prints first 1000 Pitagorean triples, but uses more
mathematics and is faster.
- primes prints first 1000 prime numbers.
- prmember prints the 2000-th prime number.
- twins prints first 1000 prime numbers twins.
- fac evaluates 10! (1*2*3...*10).
- test increase all elements of the list (1 2 3 4 5) and then
reverse the result.
- queens is a non-deterministic solution of the problem '8
It must be executed alone (not in miniOS). To do this, first compile
the program, then terminate the miniOS and type:
- pitmono is non-deterministic program, evaluating some pitagorean
It is like queens and must be executed alone.
- pitagor is like pitmono but it is addopted to be
used in miniOS.
Little changes in this program or into the pure_LISP evaluation
model may crash the evaluation.
- queens_bad is an example of incorrect non-deterministic
program. The incorrectness is a result of mixing of the laziness and
parallelism into one step. Compare it with more proper program queens.
More about problems with non-deterministic examples and their miniOS
variants you may read in file ../History.txt.
(c) Skelet, Nov 2002 in terms of GNU GPL
Mail me at home or work