4

私は顔が青くなるまでSteeleのCommonLispthe Languageを見つめてきましたが、まだこの質問があります。コンパイルした場合:

(defun x ()
  (labels ((y ()))
    5))
(princ (x))
(terpri)

これは起こります:

home:~/clisp/experiments$ clisp -c -q x.lisp
;; Compiling file /u/home/clisp/experiments/x.lisp ...
WARNING in lines 1..3 :
function X-Y is not used.
Misspelled or missing IGNORE declaration?
;; Wrote file /u/home/clisp/experiments/x.fas
0 errors, 1 warning
home:~/clisp/experiments$ 

けっこうだ。では、関数yを無視するようにコンパイラーに要求するにはどうすればよいですか?私はこれを試しました:

(defun x ()
  (labels (#+ignore(y ()))
    5))
(princ (x))
(terpri)

そしてそれはうまくいきました:

home:~/clisp/experiments$ clisp -c -q y.lisp
;; Compiling file /u/home/clisp/experiments/y.lisp ...
;; Wrote file /u/home/clisp/experiments/y.fas
0 errors, 0 warnings
home:~/clisp/experiments$ 

しかし、どういうわけか、それが私がそうすることを警告が示唆していることではないと思います。

私は何をしますか?

4

1 に答える 1

9

GNU CLISP はdeclare関数をignoredにするように求めています。

(defun x ()
  (labels ((y ()))
    (declare (ignore (function y)))
    5))

yあるいは (特に、これが実際に使用されるかどうかがユーザーに依存するマクロ展開の結果である場合)、

(defun x ()
  (labels ((y ()))
    (declare (ignorable (function y)))
    5))

(どこで書くことが期待されている場合でも(function y)、代わりに読者の略語を自由に使用できます#'y。)

于 2012-02-26T21:17:34.040 に答える