4

ステップ関数を使用して、期待される出力にどのように到達したかを確認したいのですが、機能していません。

この簡単な例のように:

(STEP (IF (ODDP 3) 'YES 'NO))

しかし、何も起こりません。

トレースステップが表示されない最適化はありますか?

オフにする方法は?

ありがとう!

4

5 に答える 5

3

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.

于 2012-11-03T16:22:53.097 に答える
3

Clozure CL はステッピングをサポートしていないと思います。IIRC はまだこの機能に資金を提供していません。Clozure CL にはインタープリターがないため (ステッピングは比較的簡単にサポートできます)、多少の作業が必要です。

他の実装ではステッピングがサポートされています。

于 2012-02-23T15:12:36.910 に答える
0

cl-user:step の代わりに cl-stepper:step を使用してください。これは、Clozure CL がサポートしていないためです。すでにquicklispをインストールしている場合は、インストールしてみてください: このように.

(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))
于 2013-10-20T05:00:39.620 に答える