[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding out if a variable is proclaimed special

>I am wondering how (in MCL, not necessarily portably) to determine if
>a variable is proclaimed special.
>Background:  As part of our application, we construct and compile
>lambda functions.  Sometimes the code we generate does not use all of
>the variables in the lambda list.  When not all variables are
>accessed, we want to include and appropriate (declare (ignore ...))
>statement.  The problem is that MCL's internal code for saving the
>special bindings is considered by the compiler to access a variable,
>so if we declare it to be ignored, then a warning message is
>generated.  We would like to spare our users these messages.

It seems to me that if your application is generating the code, then you
should be able to figure out which variables you are not using.

Clean Solution:
  Each function that adds some code to the generated function returns
another value which is the variables that it used.

Less Clean Solution:
  After you have generated the function, but before compiling it, you
could skip over the arglist and do a recursive find on all of the
arg-list parameters.

Possibly Optimal Solution:
If you are absolutely sure that you do not generate bogus code, then just do

(let ((*compiler-warnings* nil))
  (compile nil <function>))