Allow ONCE-ONLY to accept declarations
CL-USER> (let ((x 33))
(alexandria:once-only (x)
42))
; in: LET ((X 33))
; (ALEXANDRIA.0.DEV:ONCE-ONLY (X)
; 42)
; --> LET SB-INT:QUASIQUOTE SB-IMPL::|List|
; ==>
; (LET ((X #:ONCE-ONLY0))
; 42)
;
; caught STYLE-WARNING:
; The variable X is defined but never used.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
(LET ((#:X1801 33))
42)
It might be preferable to have ONCE-ONLY
accept declarations, such as IGNORABLE
. For example, the above code issues a warning for undefined variables. If ONCE-ONLY
is used in a macro that accepts keyword arguments and generates code based on whether they are provided, some variables might not be used in the resulting macroexpansion, which will cause them to emit warnings when compiled.
A suggested solution is to allow ONCE-ONLY
to understand and appropriately process declarations, so that code like this is acceptable:
(let ((x 33))
(alexandria:once-only (x)
(declare (ignorable x))
42))
It can produce the following expansion:
(LET ((#:X1808 33))
(DECLARE (IGNORABLE #:X1808))
42)