From: Barry Margolin
Subject: Re: who-calls in Lucid?
Date: 
Message-ID: <kqjk4iINNf9k@early-bird.think.com>
There are some problems with the list-callers function I posted last week,
mostly having to do with recursive functions.  Here's a revision from David
A. Duff (····@starbase.MITRE.ORG):

(defun list-callers (function-name &optional (package :all-packages) &aux (list-of-callers nil))
  (flet ((check-symbol (symbol)
	   (labels ((check-function (function ignore-list)
		      (loop for i from 4 below (sys:procedure-length function)
			    for element = (sys:procedure-ref function i) do
			    (cond ((eq element function-name) (pushnew symbol list-of-callers))
				  ((and (compiled-function-p element)
					(not (eq function element))
					(not (member element ignore-list)))
				   (funcall #'check-function element (cons function ignore-list)))))))
	     (when (fboundp symbol)
               (check-function (symbol-function symbol) nil)))))
    (if (eq :all-packages package)
	(do-all-symbols (symbol) (check-symbol symbol))
	(do-symbols (symbol (find-package package)) (check-symbol symbol))))
  list-of-callers)
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar