From: Kalle O. N. <ko...@ik...> - 2004-11-12 19:36:50
|
In SBCL 0.8.14.9, (let (x y) (setf (the (values fixnum fixnum) (values x y)) (values 1 2))) causes an error: GET-SETF-METHOD used for a form with multiple store variables. However, CLHS 5.1.2.4 says the THE is to be transferred to the newvalue form, like this: (let (x y) (setf (values x y) (the (values fixnum fixnum) (values 1 2)))) This works in SBCL, so the original form should too. I don't see anything relevant in NEWS, so I presume later versions of SBCL still have this bug. I have written an alternative setf expander for THE that seems to do the job. It does introduce an unnecessary layer of bindings, but the compiler apparently optimizes that out in typical cases. (define-setf-expander the (value-type place &environment environment) "(the VALUE-TYPE PLACE): Access PLACE and declare it's of type VALUE-TYPE. This is specified in the ANSI Common Lisp standard, section 5.1.2.4 \(THE Forms as Places). (setf (the VALUE-TYPE PLACE) VALUE) is equivalent to (setf PLACE (the VALUE-TYPE VALUE))." (multiple-value-bind (vars vals store-vars storing-form accessing-form) (get-setf-expansion place environment) (values vars vals store-vars `(multiple-value-bind ,store-vars (the ,value-type (values ,@store-vars)) ,storing-form) `(the ,value-type ,accessing-form)))) |