我收到来自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-函数需要实现特定接口f(上下文p)的worker函数。
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 conditionhttps://stackoverflow.com/questions/31225756
复制相似问题