SketchyLISP Reference Manual - Copyright (C) 2005 Nils M Holm

3 Programs

3.1 Program Execution

Each SketchyLISP expression is a program and each program is an expression. Programs are 'executed' by reducing them to their normal forms. No input/output routines exist, but the interpreter prints the normal form of each expression which has been reduced at the top level. The context of an expression is the top level, if the expression has been entered at the user's terminal or redirected from a file.

The interpreter makes no difference between upper and lower case characters, but it folds all input to lower case.

3.2 Expressions

There are multiple types of SketchyLISP expressions:

The special object () represents the empty List.

Symbols, Booleans, Procedures, and Numbers are called Atoms or atomic expressions, because they cannot be decomposed.

An Symbol is represented by a symbolic name composed of these ASCII characters:

abcdefghijklmnopqrstuvwxyz
0123456789
* + - / < = > _ ? !

A Pair is a pair of expressions represented by the form

(x . y)

where X and Y may have any type. The X part of a Pair is also called its car part and the Y part is called its cdr part. A Pair is also said to be of the type cons.

Note that the Scheme standard requires a blank character before and after the dot separating the car and cdr part of a Pair. SketchyLISP does not require this blank, so above Pair could also be written as:

(x.y)

This notation will also be used in this document.

A List is a Pair whose cdr field is either another Pair or (). The only exception is the empty List which does not have a car nor a cdr part. Each List of the form

(a1 . (a2 . ... (aN . ()) ... ))

may also be written as

(a1 a2 ... aN)

The second form is equal to the first one, but easier to handle.

Lists whose last members are not equal to () are called Improper Lists. Such lists have an Atom in their last position. They are represented using Pair notation:

(a b . c)

or

(a b.c)

The Boolean literal #t represents logical truth and #f represents logical falsity.

Numbers are represented by lists of digits with an optional leading plus or minus sign, eg:

314 -159 +265

Procedures are represented by Lambda expressions of the form

(lambda (args) term)

They will be explained in detail in the following chapter.

At any point, a comment may be placed in an expression by inserting a semicolon (;). Each comment extends up to the end of the line it has been started in. All characters are allowed in comments. To the interpreter, the entire comment looks like a single space character.

Any expression prefixed with ' is in its normal form. The interpreter displays normal forms in this way.