Suppress warning for function arguments not used i

2019-02-17 15:44发布

问题:

In lisp, I need to define a set of functions, all with the same number of arguments. However, the functions may or may not use all the arguments, leading to a spur of warning messages. For example:

(defun true (X Y) X)
[...]
; caught STYLE-WARNING:
;   The variable Y is defined but never used.

Is there a way to warn the compiler that is was intended?

回答1:

See the Common Lisp Hyperspec: Declaration IGNORE, IGNORABLE

(defun true (X Y)
  (declare (ignore y))
  X)