本文介绍了如何描述本地函数(trace)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在通用的lisp中,函数(跟踪名称)可用于查看有关对函数的调用的输出。

In common lisp, the function (trace name) can be used to see output about the calls to a function.

如果我的函数以本地作用域声明,如何描述它要跟踪?

If my function is declared with local scope, how do I describe it to trace?

例如,如何跟踪吧,如下:

eg, how do I trace bar, below:

(defun foo (x)  
  (labels ((bar (y) (format t "bar: ~a~&" y)))  
    (bar x)))  


推荐答案

使用 (TRACE ...)未由ANSI Common Lisp定义。

Tracing local functions with (TRACE ...) is not defined by ANSI Common Lisp.

某些实现具有扩展功能。请参阅。

Some implementations have extensions to do that. See for example CMU CL.

除此之外,您需要在FOO的定义中添加一些代码。例如,有一个宏可能是有用的,以便您可以将调用写入(bar-it(bar x)),并将宏扩展为打印输入和退出的代码。

Other than that, you would need add some code to the definition of FOO. For example it might be useful to have a macro so that you can write the call to bar as (trace-it (bar x)) and the macro would expand into code that prints the entry and exit.

这篇关于如何描述本地函数(trace)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 01:39