The executable portion of a program normally consists of a single defmain statement, and any number of defsub statements. These statements may appear in any order.
statement
statement ... )
(defmain progname
The defmain statement is used to define the main routine of a program. It is intended to appear as a top-level form, but may actually appear anywhere a statement may appear. (If executed as a statement, it does nothing.) Currently there is no ``command line'' or other argument list available to the program; it must either be self-contained along with its data or explicitly read data from an input stream. Defmain generates information in the output file that tells the run-time environment where to begin executing. If there are zero or more than one defmain statements in a given program, then the result of attempting to run the program is undefined.
Defmain currently also has the side effect of causing the entire standard library to be included in the output program. Right now there is only one subroutine in the standard library (named smf), so this is not too burdensome.
statement
statement ... )
(defsub subname ( arg arg ...)
Defsub statements are used to define subroutines within a program. They are intended to appear only as top-level forms, but may actually appear anywhere that a statement may appear. (If executed as a statement, a defsub construct does nothing.) If there are two defsub statements with the same subname in a given program, then the result of attempting to execute that program is undefined.
The formal arguments may be accessed as read-write variables within the body of the subroutine. On entry to the subroutine, the values of these variables are bound to the values of the actual arguments that were passed in via the call statement in the caller. The call statement must pass exactly the number of arguments required by the subroutine or else the behavior of the subroutine is undefined. On exit, the values of the argument variables become the new values of the actual arguments (see the description of call).
Any subroutine may also be called in reverse; see rcall.