Lisp HUG Maillist Archive

Compiler bug?

I have a funcion that basically does something like the following:

(defun case-closed(n)
   (typecase n
     (ratio (/ n 2))
     (otherwise
      (case n
        (0.0 1)
        (0.5 2)
        (otherwise 'wrong)))))

Now, I did not get the results that I was expecting. The case  
statement did not seem to be working.
It seems, though, that I get the correct result if the function is  
interpreted as opposed to being compiled:

<COMPILED FUNCTION case-closed>

;(case-closed 1/2) -> 1/4

;(case-closed 0.5) -> WRONG

<INTERPRETED FUNCTION case-closed>

;(case-closed 1/2) -> 1/4

;(case-closed 0.5) -> 2

It seems that if I remove the typecase statement the (case-closed  
0.5) gives the expected result both interpreted and compiled.


Regards,

Mika Kuuskankare
Researcher
Department of Doctoral Studies in Musical Performance and Research
Sibelius Academy

Henkilökohtainen postiosoite/Personal post address
PL 342 - PO Box 342
FIN-00121 Helsinki, FINLAND
Tel: +358 (0)40 5415 233
Skype: mkuuskan





Re: Compiler bug?

Unable to parse email body. Email id is 5439

Updated at: 2020-12-10 08:48 UTC