From: Kevin R. <kp...@ma...> - 2008-12-20 17:34:09
|
On Dec 20, 2008, at 12:24, Nikodemus Siivola wrote: > 243: "STYLE-WARNING overenthusiasm for unused variables" > (observed from clx compilation) > In sbcl-0.7.14, in the presence of the macros > (DEFMACRO FOO (X) `(BAR ,X)) > (DEFMACRO BAR (X) (DECLARE (IGNORABLE X)) 'NIL) > somewhat surprising style warnings are emitted for > (COMPILE NIL '(LAMBDA (Y) (FOO Y))): > ; in: LAMBDA (Y) > ; (LAMBDA (Y) (FOO Y)) > ; > ; caught STYLE-WARNING: > ; The variable Y is defined but never used. > > I don't see why this would be wrong. From the perspective of the > LAMBDA, Y is indeed unused without the appropriate declaration. Unless > someone can tell me otherwise, I'll flush this. One could argue that the user has used Y in the body, and so no warning should be emitted regardless of what the macro actually does. However, there is no way to tell that the "use" is as a variable, so that's not sound; and if the above code is deliberate one can write: (DEFMACRO BAR (X) `(PROGN ,X NIL)) (Is there a better way to suppress unused warnings for variables from an arbitrary location? (IGNORABLE can't be used since (at least by most implementations) it can only be used directly within the form which binds the variable, not arbitrarily deep.)) -- Kevin Reid <http://homepage.mac.com/kpreid/> |