Re: Diagnostic output -- how-to?
- From: pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
- Date: Fri, 28 Aug 2009 17:55:43 +0200
Alessio Stalla <alessiostalla@xxxxxxxxx> writes:
On Aug 28, 4:13 pm, Mirko <mirko.vuko...@xxxxxxxxx> wrote:
Supposed I have a function such as:
(defun foo (...)
(when *trace-opt* (tracing-ouput some data))
I would like the output generated by `tracing-output' to be something
In FOO: tracing output
My problem is to get the `FOO' information. I would prefer not to
have to encode it in the (when *trace-opt*...)
DEFUN is not the only way to create a function. Anonymous functions
exist in Lisp too. Plus, a given function can be referenced by the
function cell of more than one symbol. So, it's not always clear what
the current function name is. Also, you cannot (portably, at least)
get a reference from the currently running function to the object
representing the function itself.
Of course, you would also define a LOGGING-LAMBDA macro to make
anonymous functions similar to DEFINE-LOGGING-FUNCTION.
(Or rather, TRACING-LAMBDA and DEFINE-TRACING-FUNCTION).
(defmacro DEFUN/LOG (name args &body body)
`(defun ,name ,args
(let ((*function-name* ',name))
This breaks declarations and document string.