>>>>> "Martin" == Martin Cracauer <[EMAIL PROTECTED]> writes:

    Martin> Paul Werkowski wrote on Tue, May 14, 2002 at 11:45:13AM -0400: 
    >> 
    >> Change that DECLARE to something like
    >> 
    >> (declare (type (double-float #.(float most-negative-fixnum 1d0)
    >> #.(float most-positive-fixnum
    >> 1d0)) q))

    Martin> Thanks.  I already tried that, it doesn't help.

    Martin> However, here is what helps:

    Martin> (defun test-double-crazy (p)
    Martin>   (declare (fixnum p))
    Martin>   (let ((q (float p 1.0d0)))
    Martin>     (declare (double-float q))
    Martin>     (prog1 (the fixnum (truncate q)))))

    Martin> Note the prog1, it fixes the warning and the consing.

    Martin> I figure the compiler can't tell I will not use the secondary return
    Martin> value, but I don't understand why the (the fixnum ...) didn't take
    Martin> care of that.

I took a look at this.  test-double actually returns both values, and,
according the CLHS, this is required behavior::

        It is permissible for form to yield a different number of
        values than are specified by value-type, provided that the
        values for which types are declared are indeed of those
        types. Missing values are treated as nil for the purposes of
        checking their types.

        Regardless of number of values declared by value-type, the
        number of values returned by the the special form is the same
        as the number of values returned by form.

So, saying (the fixnum (truncate ...)) just says the first result is a
fixnum.  CMUCL is correctly returning the second result, which is a
double-float.

So, if you really only wanted one value, you need either the prog1 you
have above or just use (values (truncate q)) to return the first
value.  

Note that CMUCL correctly determines that truncate returns a fixnum
here without you having to say so.

Ray
 

Reply via email to