Re: Diagnostic output -- how-to?



Alessio Stalla <alessiostalla@xxxxxxxxx> writes:

On Aug 28, 4:13 pm, Mirko <mirko.vuko...@xxxxxxxxx> wrote:
Hello,

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
linke this:

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))
,@body)))

This breaks declarations and document string.



--
__Pascal Bourguignon__
.



Relevant Pages