"lyle.graham" <[EMAIL PROTECTED]> writes:
> especially if there is more than one function which includes a PRINTVARS form. In
> order to do this, is there any way that one can automatically get the function name
> in the necessary manner?
You could use the debugger interface to walk the stack. E.g. you
could define a function GET-SOURCE-CONTEXT that returns the name of
the currently executed function:
(defun get-source-context ()
(di:debug-function-name
(di:frame-debug-function
(di:frame-down (di:top-frame)))))
and PRINTVARS could look like this:
(defmacro printvars (&rest vars)
`(format t "PRINTVARS (in ~S): ~{~A ~}"
(get-source-context)
(list ,@(loop for var in vars
append `((quote ,var) ,var)))))
If you compile your code you can play tricks with compiler macros ala:
(define-compiler-macro get-source-context ()
`(quote ,(nth-value 1 (c::find-original-source c::*current-path*))))
This replaces the call to GET-SOURCE-CONTEXT with a quoted list, which
might be more efficient than using debugger functions.
Both variants don't work particularly well inside lambdas, though.
Helmut.