Path: utzoo!attcan!uunet!mcvax!ukc!etive!aiva!jeff From: jeff@aiva.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.lisp Subject: Re: Franz-lisp from Sun User's Group bug fix Keywords: arrays, sun, franz-lisp Message-ID: <582@aiva.ed.ac.uk> Date: 11 Sep 88 17:34:56 GMT References: <465@sce.UUCP> Reply-To: jeff@uk.ac.ed.aiva (Jeff Dalton) Organization: Dept. of AI, Univ. of Edinburgh, UK Lines: 43 In article <465@sce.UUCP> fred@sce.UUCP (Fred J. Kaudel) writes: >Hello, Franz-lisp version 38.92 as distributed from the Sun User's Group >distribution tape number 2 [...] >-has anyone found a fix for the zerop bug in compiled lisp code on the suns? > More specifically, (zerop 0) and (zerop 0.0) both evaluate to t on the vax, > but evaluate to t and nil, respectively, when compiled on the sun using > Liszt version 8.39a (comes with lisp on the tape). This problem is > quite irritating since it makes code non-portable. Well, I've fixed it, and I know someone else has too because I've seen two different fixes. My fix looks somewhat suspect, I know, but is not actually worse than similar code elsewhere in Liszt. The problem is in cm-zerop in liszt/func.l. The comment below will make sense if you look at (1) the VAX code, (2) the current definition of cm-zerop, and (3) the code for cm-=& in liszt/fixnum.l. ; [begin jwd] The trick has to be a bit different on the 68k than on the ; VAX because the NULL test doesn't work unless NIL is at address zero. ; However, expanding (zerop x) as (=& 0 x) won't work either, because ; =& will compile this as an address comparison and not all floating ; zeros have the same address (much less the address of fixed 0). ; Therefore, we have to do some explicit dereferencing, just as =& ; does in the general case. Then (zerop x) expands, modulo bignums, ; to (eq (cdr 0) (cdr x)). #+for-68k (defun cm-zerop nil (cond ((atom (cadr v-form)) `(and (eq (cdr 0) (cdr ,(cadr v-form))) (not (bigp ,(cadr v-form))))) (t (let ((gnsy (gensym))) `((lambda (,gnsy) (and (eq (cdr 0) (cdr ,gnsy)) (not (bigp ,gnsy)))) ,(cadr v-form)))))) ; [end jwd] Jeff Dalton, JANET: J.Dalton@uk.ac.ed AI Applications Institute, ARPA: J.Dalton%uk.ac.ed@nss.cs.ucl.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!J.Dalton