Page 1 of 1

Disable compiler warnings for special variables

Posted: Sun Jun 08, 2014 10:13 am
by porky11
If I create functions using a undeclared special variable like this

Code: Select all

(defun some-special-function ()
  (do-something-with *special-variable*))
,
the compiler warns me, every time.

The special variables are only defined temporary:

Code: Select all

(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

Posted: Sun Jun 08, 2014 3:33 pm
by macrolyte
Did you search for "disable compiler warnings sbcl" ?:
I found all this in under 10 minutes (plus my lousy typing...)

Re: Disable compiler warnings for special variables

Posted: Sun Jun 08, 2014 5:08 pm
by nuntius
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.

Code: Select all

(defun some-special-function ()
  (declare (special *special-variable*))
  (do-something-with *special-variable*))

Re: Disable compiler warnings for special variables

Posted: Thu Jun 12, 2014 3:30 am
by porky11
Thanks @nuntius, that's what I meant,
I didn't know, it's possible to declare variables special in this context