Expression Structure

Despite the apprent similarity between data and programs (their source representations are nearly identical), not all data are valid expressions.

Expressions are defined recursively, as is usual for programming language specifications.

Simple Expressions


The simplest expression is a literal expression. Literal expressions are also known as self-evaluating data, because the value of a literal expression is the corresponding datum. Characters, strings, numbers, booleans, and keywords are all valid literal expressions.

1 1

"foo" "foo"

bob: bob:

Variable References

The next simplest expression is the variable reference. An identifier is an expression which means "look up and return the current value of the variable with this name".

Procedure Calls

The third kind of expression is the function call, or combination. Syntactically, a function call expression is an open parenthesis followed by one or more expressions followed by a close parenthesis.

There must be at least one expression between the parentheses, because the value of the first expression is the function to be called. The remaining expressions are all evaluated and their values are the arguments to the function.

The earlier example expression, (+ 1 2) illustrates the three kinds of expressions, in order of execution: literal, variable reference, and procedure call.

1 and 2 are literal expressions which evaluate to the numbers 1 and 2, respectively.

Then, + is an expression which means "look up and return the value of the variable named +".

Finally, the whole thing is a combination which means to call the procedure returned by the first expression (typically, the value of the variable named + is a function which adds its arguments together) with the arguments 1 and 2. The usual addition function would return 3 in this case.

Special Forms

The fourth kind of expression is really a large class of every other kind of expression, and are called special forms. Any identifier or parenthesized sequence of forms starting with an identifier is potentially a special form. The only way to tell is to know whether or not the variable named by the identifier is a special form compiler[1].

Binding constructs

A useful common class of special forms are those used to introduce new program variables. These are known as binding constructs.

let, letrec, bind,

Conditional constructs

if, or, and,

Procedural abstraction




There are several kinds of special form compilers: syntax extensions, rewriter macros, and primitive compilers