Page:Scheme - An interpreter for extended lambda calculus.djvu/2



Section 1: The SCHEME Reference Manual
SCHEME is essentially a full-funarg LISP. expressions need not be d,  ed, or  ed when passed as arguments or returned as values; they will evaluate to closures of themselves.

All LISP functions (i.e., s,  s, and  s, but not  s,  s, or  s) are primitive operators in SCHEME, and have the same meaning as they have in LISP. Like  expressions, primitive operators and numbers are self-evaluating (they evaluate to trivial closures of themselves).

There are a number of special primitives known as s which are to SCHEME as  s are to LISP. We will enumerate them here.     This is the primitive conditional operator. It takes three arguments. If the first evaluates to non-, it evaluates the second expression, and otherwise the third.     As in LISP, this quotes the argument form so that it will be passed verbatim as data. The abbreviation " " may be used instead of " ".     This is analogous to the MacLISP  primitive (but note that the   must appear explicitly!). It is used for defining a function in the "global environment" permanently, as opposed to  (see below), which is used for temporary definitions in a local environment. takes a name and a lambda expression; it closes the lambda expression in the global environment and stores the closure in the LISP value cell of the name (which is a LISP atom).    <dd> We have decided not to use the traditional  primitive in this interpreter because it is difficult to define several mutually recursive functions using only. The solution, which Hewitt [Smith and Hewitt] also uses, is to adopt an ALGOLesque block syntax:

This has the effect of evaluating the expression in an environment where all the functions are defined as specified by the definitions list. Furthermore, the functions are themselves closed in that environment, and not in the outer environment; this allows the functions to call themselves and each other recursively. For example, consider a function which counts all the atoms in a list structure recursively to all levels, but which doesn't count the s which terminate lists (but  s in the   of some list count). In order to perform this we use two mutually recursive functions, one to count the  and </dd> </dl>