4

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!

2
  • 1
    "It is technically permissible for a conforming implementation to take no action at all other than normal execution of the form. In such a situation, (step form) is equivalent to, for example, (let () form). In implementations where this is the case, the associated documentation should mention that fact." (CLHS) I have no idea, whether Clozure resorts to this "solution"... Commented Feb 23, 2012 at 14:34
  • here's a relevant question regarding SBCL: stackoverflow.com/questions/8617064/… Commented Feb 23, 2012 at 15:06

5 Answers 5

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

It is now at framagit: framagit.org/com-informatimago/com-informatimago (with the issues list) there's also a mirror at gitlab: gitlab.com/com-informatimago/com-informatimago and anotherw one at github: github.com/informatimago/lisp
4

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.

1 Comment

Thank you so much, I never thought I would be able to find the link again, as I had bookmarked it on a previous computer that crashed. This is exactly the solution on how to trace in CCL. Thank you so much and for the Debug With OpenMCL link.
3

I don't think Clozure CL supports stepping. IIRC nobody has funded this feature yet. It would need some work, since Clozure CL lacks an interpreter (where stepping could be supported relatively painless).

Other implementations support stepping.

1 Comment

A quick look at the source confirms that. From ccl:lib;macros.lisp: (defmacro step "…" (form) form).
1

This library is not distributed on quicklisp anymore however it builds successfully when installed as a local quicklisp project.

Comments

0

use cl-stepper:step instead of cl-user:step , 'cause Clozure CL don't support it. if you have already installed quicklisp, try to install it : like this.

(ql:quickload "com.informatimago.common-lisp.lisp.stepper") (defpackage :test (:use :cl-stepper)) (in-package :test) (def bar (hoge) ;; define some function ) (step (bar 3)) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.