我从sbcl编译器收到警告,该变量已定义但未使用。而且编译器是正确的。我想摆脱警告,但不知道如何去做。这是一个例子:
(defun worker-1 (context p)
;; check context (make use of context argument)
(if context
(print p)))
(defun worker-2 (context p)
;; don't care about context
;; will throw a warning about unused argument
(print p))
;;
;; calls a given worker with context and p
;; doesn't know which arguments will be used by the
;; implementation of the called worker
(defun do-cmd (workerFn context p)
(funcall workerFn context p))
(defun main ()
(let ((context ()))
(do-cmd #'worker-1 context "A")
(do-cmd #'worker-2 context "A")))
do-cmd-function期望实现特定接口f(context p)的辅助函数。
sbcl编译器将引发以下警告:
in: DEFUN WORKER-2
; (DEFUN WORKER-2 (CONTEXT P) (PRINT P))
;
; caught STYLE-WARNING:
; The variable CONTEXT is defined but never used.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句