[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Program Call Structure
I have considered building a browser to inspect the call structure
of a Lisp program, but Common Lisp does not seem to provide the
primitives needed for this. Theoretically one can use a code walker to
determine the call structure, but this does not really work because too
many implementations include macros that expand into implementation
specific special forms. Furthermore, to make it work smoothly there
needs to be some way to determine the source file of a function,
and this functionality is missing from Common Lisp. The Lispm
function who-calls provides the required information, but it is
not implemented efficiently, and it is not standard.
This table describes four functions which would provide the required
primitive functionality to implement a browser capable of showing
the call structure of a Lisp program (similar perhaps to InterLisp's
MasterScope).
Function To Functions Function To Variables
---------------------------------------------
Upward | Who-Calls | Who-References |
|-----------------------|-------------------|
Downward | What-Calls | What-References |
---------------------------------------------
Who-Calls: Maps from a function spec to a list of functions that call it.
What-Calls: Maps from a function spec to a list of functions called by it.
Who-References: Maps from a variable to a list of functions that reference it.
What-References: Maps from a function spec to a list of variables
referenced by it.
None of these functions produce any printed output. That functionality can
be implemented using these primitives if desired.
I have not tried to specify exactly what a function-spec means. At least
it should include a symbol that names a Defuned function. Compiled
function objects, generic functions and methods should also be acceptable.