Disable compiler warnings for special variables

Discussion of Common Lisp
Post Reply
porky11
Posts: 25
Joined: Fri May 02, 2014 6:46 am

Disable compiler warnings for special variables

Post by porky11 » Sun Jun 08, 2014 10:13 am

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.

macrolyte
Posts: 40
Joined: Sat Jan 25, 2014 8:56 pm
Location: The wilderness of North America

Re: Disable compiler warnings for special variables

Post by macrolyte » Sun Jun 08, 2014 3:33 pm

Did you search for "disable compiler warnings sbcl" ?:
I found all this in under 10 minutes (plus my lousy typing...)

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: Disable compiler warnings for special variables

Post by nuntius » Sun Jun 08, 2014 5:08 pm

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*))

porky11
Posts: 25
Joined: Fri May 02, 2014 6:46 am

Re: Disable compiler warnings for special variables

Post by porky11 » Thu Jun 12, 2014 3:30 am

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

Post Reply