[Openmcl-devel] Spurious compiler warning?

Gary Byers gb at clozure.com
Fri Dec 9 11:07:25 PST 2011

You can basically use a TYPE declaration to refer to any visible
"variable name".  (The terminology's a little confusing, because the
term "variable" is defined in to be roughly "a symbol that's
not a symbol macro", but the entry for TYPE declarations describes how
such declarations affect symbol macros.)  The code as written was
perfectly legal, and CCL only stopped warning about it a few hours ago
in the trunk.

It's sometimes useful (and perfectly legal) to write code like:

(let ((x ...))
   (if (typep x 'fixnum)
     (locally (declare fixnum x)
       (arithmetic-involving x)))

Outside of that inner declaration, nothing's asserted about the type
of X; within the scope of that declaration, it's declared to be a FIXNUM
(and "the results are undefined" if it isn't.)

Declaring that (the expansion of) a symbol-macro is of a certain type
might be useful.  Declaring that a symbol that names a symbol macro is
SPECIAL isn't meaningful.  There are some other declarations that apply
to variables (IGNORE/IGNORABLE) where the spec doesn't explicitly say
that the declaration can apply to symbol macros but where that might
be at least somewhat meaningful or the grounds for warning about it
aren't that strong; the recent change in the trunk just allows TYPE
declarations to apply to symbol macros without warning.

On Fri, 9 Dec 2011, Tim Bradshaw wrote:

> On 8 Dec 2011, at 20:35, Bit Twiddler wrote:
>> (defmethod transform-position ((transformation standard-translation) x y)
>>  (with-slots (dx dy) transformation
>>    (let ((x (coordinate x))
>>          (y (coordinate y)))
>>      (declare (type coordinate dx dy x y))
>>      (values (+ x dx) (+ y dy)))))
> You need to declare the types where the "variable" (presumably symbol macro) is bound.  So this should be, I think:
> (defmethod transform-position ((transformation standard-translation) x y)
> (with-slots (dx dy) transformation
>   (declare (type coordinate dx dy))
>   (let ((x (coordinate x))
>         (y (coordinate y)))
>     (declare (type coordinate x y))
>     (values (+ x dx) (+ y dy)))))
> My CCL (trunk) is quiet for this.
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel

More information about the Openmcl-devel mailing list