Style warning: unused variable

I have a couple of solutions where I iterate over a hash-table, but only use the key:

  #'(lambda (key val) (do-something-with key))
;   The variable VAL is defined but never used.

I like to resolve these style warnings, but is there a way to suppress this? Some other languages have a “disregard this argument” variable (e.g. elixir and underscore). Does common-lisp do anything similar?

You would use declare to tell Common Lisp that a variable can be ignored. Many (all?) forms that define scopes have an optional “declaration” for this.

Specifically you say (declare (ignore <variables...)

For example:

(define foo (x y)
  "A function which FOOs X but totally ignores Y"
  (declare (ignore y))
  (+ 13.5 x))

In your case you would add (declare (ignore val)) after the argument list but before the body.

See the documentation on declare (CLHS: Symbol DECLARE) for both where it can be used and what declarations can be made.