Suppress warning for function arguments not used in LISP

前端 未结 1 1815
-上瘾入骨i
-上瘾入骨i 2021-01-05 10:09

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 warnin

相关标签:
1条回答
  • 2021-01-05 10:13

    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.

    0 讨论(0)
提交回复
热议问题