I want to use a step function to see how it went to the expected output, but it's not working.
Like this simple example:
(STEP (IF (ODDP 3) 'YES 'NO))
but nothing happens.
Is there any optimization that makes me can't see the trace steps ???
How to turn it off?
Thanks!
It's because CL:STEP is not implemented on CCL that I implemented com.informatimago.common-lisp.lisp.stepper. You can get it with quicklisp. The documentation is at: https://gitorious.org/com-informatimago/com-informatimago/source/2b53ae44e8fa4d040fafcf4d93976500a8e464dc:common-lisp/lisp/stepper-packages.lisp#L146
STEP is not supported in CCL.
Solution for TRACE:
When a (globally named) function FOO is defined with DEFUN, the compiler is allowed to assume that functional references to that function name refer to the function being defined (unless they're lexically shadowed); it can therefore skip the implicit SYMBOL-FUNCTION ("call whatever is in the function cell of FOO") on a self-call (a call to FOO from within FOO.) This saves an instruction or two on those calls, but (since TRACE works by changing what SYMBOL-FUNCTION returns) those inlined self-calls can't be traced.
However, the compiler can't do this (can't even assume that something defined by DEFUN won't be redefined later) if the function name is declared NOTINLINE at the point of the self call:
example:
? (defun fact (x acc)
(declare (notinline fact))
(if (= x 0)
acc
(fact (- x 1) (* x acc))))
? (trace fact)
NIL
? (fact 3 1)
0> Calling (FACT 3 1)
1> Calling (FACT 2 3)
2> Calling (FACT 1 6)
3> Calling (FACT 0 6)
<3 FACT returned 6
<2 FACT returned 6
<1 FACT returned 6
<0 FACT returned 6
? (step (fact 3 1))
0> Calling (FACT 3 1)
1> Calling (FACT 2 3)
2> Calling (FACT 1 6)
3> Calling (FACT 0 6)
<3 FACT returned 6
<2 FACT returned 6
<1 FACT returned 6
<0 FACT returned 6
That's the way to say to the compiler, "as a matter of policy, I'd rather have the ability to trace functions which call themselves and are defined with DEFUN and don't care about saving a few cycles per self-call".
from: DebugWithOpenMCL
or Evaluate the following form:
(DECLAIM (OPTIMIZE (DEBUG 3)))
before defining any function to be traced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With