[ ^ CSE 341 | section index | <-- previous | next -->]

Syntax: special forms

Scheme's syntax is minimal, but we unfortunately can't scrub the syntactic slate completely clean. To make a language fully general, we require some "special forms".

The pseudocode for evaluating a Scheme expression, therefore, is something like the following:

(evaluate list) = evaluate (car list) if (car list) is a special form, then: process the special form else: evaluate each of the remaining items in the list apply the (car list) to the other items (i.e., pass the other items as arguments)

You've already seen one special form:

    (define symbol value)

Why must this be a special form? Here's another:

    (if (predicate)
        then-value/consequent
        else-value/alternative)

Why must if be a special form?

Try defining an abs function using the above two special forms:










Last modified: Wed Mar 29 20:11:29 PST 2000