我正在使用sbcl 1.4.6并且我有这种行为:
* (trace string<)
(STRING<)
* (string< "hola" "pato")
0: (STRING< "hola" "pato")
0: STRING< returned 0
0
* (defun test-without-cond (str)
(string< "hola" str))
TEST-WITHOUT-COND
* (test-without-cond "pato")
0
如果函数已在公共lisp中定义,则在用户定义的函数内使用时,我无法使用跟踪。如果我定义函数
,这不是问题* (defun my-string< (str) (string< str "hello"))
MY-STRING<
* (trace my-string<)
(MY-STRING<)
* (defun test-2 (str) (my-string< str))
TEST-2
* (test-2 "gato")
0: (MY-STRING< "gato")
0: MY-STRING< returned 0
0
为什么会这样?
答案 0 :(得分:6)
可追踪的内容取决于实施和各种设置。
对于SBCL,请阅读手册:Open Coding and Inline Expansion
但是SBCL现在也有一个解释器,看起来你可以从解释代码中跟踪对CL函数的调用:
* (setf *evaluator-mode* :interpret)
:INTERPRET
* (trace string<)
(STRING<)
* (defun test-without-cond (str)
(string< "hola" str))
TEST-WITHOUT-COND
* (test-without-cond "pato")
0: (STRING< "hola" "pato")
0: STRING< returned 0
0
*
请注意,人们可能需要小心跟踪核心功能,因为它们可以被调用很多......