[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Not an] Error with multiple-value-setq...
Date: Fri, 9 May 86 12:54 CDT
From: David D. Loeffler <Loeffler@MCC.ARPA>
Date: Thu 8 May 86 21:10:24-CDT
From: Nat Ballou <AI.BALLOU@MCC.ARPA>
Using Release 6.1, the following definition does not perform
correctly when compiled:
(defun foo (&aux a b) (multiple-value-setq (a b) (floor 3 2)) (list a b))
The function returns (1 1) when interpreted, but returns (1 NIL)
when compiled. Multiple-value-setq is common lisp, however, the
Zeta lisp form Multiple-value has the same problem.
The problem is not with multiple-value-setq it is with floor
and other numeric functions that return 2 values.
If I write the function:
(defun foo1 ()
(floor 3 2))
The compiled and interpreted versions return one and two values respectively.
If foo3 and foo4 are defined:
(defun foo3 ()
(let (a b)
(multiple-value-setq (a b)
(foo4 3 4))
(list a b)))
(defun foo4 (x y)
(values y x))
Then you get the same result in both the interpreted and compiled versions.
[hoss mailing list added to distribution]
This error ONLY occurs when ALL the arguments are constant (it appears
to be caused by an erroneous compiler optimization). It happens with
the round and truncate functions also. The following is a workaround
if you *really* need to call these guys with all constant arguments:
(defun correct-floor (a b) (floor a b))
This should work in all cases, compiled or interpreted, since the
compiler doesn't know how to optimize out calls to it.
(Of course your program will run faster if you simply do what the
compiler was trying to do and replace the call with its (constant)
results in your code.)