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?
See the Common Lisp Hyperspec: Declaration IGNORE, IGNORABLE
A variable is not used. Ignore it.
(defun true (x y)
(declare (ignore y))
x)
Above tells the compiler that y
is not going to be used.
The compiler will complain if it is used. It will not complain if it is not used.
A variable might not be used. Don't care.
(defun true (x y)
(declare (ignorable y))
x)
Above tells the compiler that y
might not be used.
The compiler will not complain if it is used and also not if it is not used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With