LISP - Introduction

I’m still trying to restore ALGOL 68 from D4.0 and although I’ve had some great help from the folks on the H390-MTS list I have not yet got a working system running. While I continue to work on this, let’s look at a completely different language - LISP.

LISP overview

LISP is one of the oldest high level languages still in use today, with the original version developed by John McCarthy at MIT in 1958. It combines procedural, functional and metaprogramming elements and has a unique syntax based on balanced parentheses that make it unlike any other language of its time.

LISP gained popularity in the 1960s and 70s during the AI boom, when the language evolved rapidly and there was even special hardware built in order to run it efficiently. This died down towards the end of the 20th century, but it remains influential with concepts from LISP such as lambdas recently being added to languages such as Java and C++. Common Lisp implementation continue to be used today, and LISP has been used as an extension language, most famously in Emacs and AutoCAD.

LISP on MTS

The primary LISP environment in MTS, *LISP, was developed at the Mental Health Research Institute at UM. (Not an organisation you’d think would be implementing a programming language; the Wikipedia article on Brian Wilcox, one of MTS LISP’s authors, mentions that it was developed in order to play the game of Go.). It is based on LISP 1.5, one of the earliest versions of LISP that was in wide use, with some extensions drawn from later LISPs and customisations for MTS.

There are a number of other LISPs available on MTS, such as the University of Tokyo’s UTILISP, that I will look at later.

Prerequisites

No special installation instructions to get LISP running - just do the standard D6.0 setup as described in this guide and then sign on as a regular user such as ST01.

Using *LISP

LISP is an interpreted environment. Running *LISP on its own will allow you to start entering expressions which will be immediately evaluated. It’s possible to load expressions from a text file by providing it as the scards parameter to *LISP; after the file is read you will remain in the LISP expression reader. To run a complete program and return to MTS afterwards, make the last expression be (STOP).

There is a rudimentary line editor available via (EDIT fn) but it’s easier to do this outside of LISP.

You can also save the current state of the system (to a binary file) with (CHECKPOINT filename) and reload it in a later session with (RESTORE filename).

It’s possible to compile expressions to machine code with (COMPILE fn) but this is unlikely to be worthwhile as MTS on Hercules is fast enough.

Hello world

Here’s a transcript of a session where we run a Hello world program. This assumes the source code is contained in the file hello.l.

# $list hello.l
 
       1      ; LISP Hello World program
       2     (REPEAT '(PRINT '"Hello, world!") 5)
       3     (STOP)
# $run *lisp scards=hello.l
# Execution begins   20:54:36 
     WELCOME TO LISP/MTS
>    Hello, world!
>    Hello, world!
>    Hello, world!
>    Hello, world!
>    Hello, world!
>    Hello, world!
# Execution terminated   20:54:36  T=0.002 

Note the message is actually printed six times, as the value of the REPEAT expression is printed by the interpreter.

Further information

MTS Volume 8 describes the LISP language and its implementation in MTS *LISP.

The original LISP 1.5 reference from MIT gives a more formal description of the original version of the language.

John McCarthy’s paper on the History of Lisp gives context on how and why LISP came about.

Comments

comments powered by Disqus