Opened 11 years ago

Last modified 11 years ago

#436 assigned defect

Failure expanding defsetf with &rest parameter

Reported by: dbmcclain Owned by: gb
Priority: normal Milestone:
Component: ANSI CL Compliance Version:
Keywords: defsetf Cc:

Description

Example:

(defsetf value (place &rest args) (new-value)

`(set-value ,new-value ,place ,@args))

Try it out with the following example declarations as a backdrop:

(defmethod value-at ((vec vector) &key at)

(aref vec at))

(defun value (x &rest args &key at)

(if (null at)

x

(apply #'value-at x args)))

(defparameter myvec (make-array 5))

next try:

(setf (value myvec :at 3) 15)

An explicit macroexpand produces a correct conversion:

(LET* ((#:G1204 MYVEC)

(#:G1203 :AT) (#:G1202 3))

(DECLARE (IGNORABLE #:G1204 #:G1203 #:G1202)) (MULTIPLE-VALUE-BIND (#:G1201) 15

((LAMBDA (#:PLACE &REST #:ARGS)

(SET-VALUE #:G1201 #:PLACE . #:ARGS))

#:G1204 #:G1203 #:G1202)))

But in actual use at runtime, the attempted expansion produces an error:

value #:ARGS is not of the expected type LIST.

[Condition of type TYPE-ERROR]


As a workaround, I defined an alternative to defsetf:

(defun (setf value) (new-value place &rest args)

(apply #'set-value new-value place args))

While this may actually be a preferable way to do things, the fact that the defsetf expansion produces an error is still troubling.

  • DM

Change History (1)

comment:1 Changed 11 years ago by gb

  • Status changed from new to assigned

The expansion isn't correct (it's basically a lot of binding stuff around a function call with a dotted arglist.)

Note: See TracTickets for help on using tickets.