Disable compiler warnings for special variables

Discussion of Common Lisp

Disable compiler warnings for special variables

Postby 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.
porky11
 
Posts: 9
Joined: Fri May 02, 2014 6:46 am

Re: Disable compiler warnings for special variables

Postby 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...)
macrolyte
 
Posts: 40
Joined: Sat Jan 25, 2014 8:56 pm
Location: The wilderness of North America

Re: Disable compiler warnings for special variables

Postby 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*))
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA

Re: Disable compiler warnings for special variables

Postby 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
porky11
 
Posts: 9
Joined: Fri May 02, 2014 6:46 am


Return to Common Lisp

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests