19.3 The Standard Lisp Cross Reference Program

CREF is a Standard Lisp program for processing a set of Standard LISP function definitions to produce:

  1. A “summary” showing:
    1. A list of files processed;
    2. A list of “entry points” (functions which are not called or are only called by themselves);
    3. A list of undefined functions (functions called but not defined in this set of functions);
    4. A list of variables that were used non-locally but not declared GLOBAL or FLUID before their use;
    5. A list of variables that were declared GLOBAL but not used as FLUIDs, i.e., bound in a function;
    6. A list of FLUID variables that were not bound in a function so that one might consider declaring them GLOBALs;
    7. A list of all GLOBAL variables present;
    8. A list of all FLUID variables present;
    9. A list of all functions present.
  2. A “global variable usage” table, showing for each non-local variable:
    1. Functions in which it is used as a declared FLUID or GLOBAL;
    2. Functions in which it is used but not declared;
    3. Functions in which it is bound;
    4. Functions in which it is changed by SETQ.
  3. A “function usage” table showing for each function:
    1. Where it is defined;
    2. Functions which call this function;
    3. Functions called by it;
    4. Non-local variables used.

The program will also check that functions are called with the correct number of arguments, and print a diagnostic message otherwise.

The output is alphabetized on the first seven characters of each function name.

19.3.1 Restrictions

Algebraic procedures in REDUCE are treated as if they were symbolic, so that algebraic constructs will actually appear as calls to symbolic functions, such as AEVAL.

19.3.2 Usage

To invoke the cross reference program, the switch CREF is used. on cref causes the cref program to load and the cross-referencing process to begin. After all the required definitions are loaded, off cref will cause the cross-reference listing to be produced. For example, if you wish to cross-reference all functions in the file, and produce the cross-reference listing in the file tst.crf, the following sequence can be used:

        out ~tst.crf~;  
        on cref;  
        off cref;  
        shut ~tst.crf~;

To process more than one file, more IN statements may be added before the call of off cref, or the IN statement changed to include a list of files.

19.3.3 Options

Functions with the flag NOLIST will not be examined or output. Initially, all Standard Lisp functions are so flagged. (In fact, they are kept on a list NOLIST!*, so if you wish to see references to all functions, then CREF should be first loaded with the command load cref, and this variable then set to NIL).

It should also be remembered that any macros with the property list flag EXPAND, or, if the switch FORCE is on, without the property list flag NOEXPAND, will be expanded before the definition is seen by the cross-reference program, so this flag can also be used to select those macros you require expanded and those you do not.