This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Disable compiler warnings for special variables

4 posts · 4434 views

If I create functions using a undeclared special variable like this
(defun some-special-function ()
  (do-something-with *special-variable*))
,
the compiler warns me, every time.

The special variables are only defined temporary:
(let ((*special-variable* nil))
  (declare (special *special-variable*))
  (some-special-function))
if I used defparameter (/etc.) i could forget to reinitialize the special variables or call the function in the wrong context.

How can I turn off the compiler warnings (in SBCL)?
It would be best to only turn off the warnings for these vars.

Re: Disable compiler warnings for special variables

Just be careful. SBCL warnings are generally quite helpful.

Given your goals, the best way to clear the warnings is to declare the variables in the function definition.
(defun some-special-function ()
  (declare (special *special-variable*))
  (do-something-with *special-variable*))

Re: Disable compiler warnings for special variables

Thanks @nuntius, that's what I meant,
I didn't know, it's possible to declare variables special in this context