[anaphora-devel] Bug in internal-symbol-macrolet setf expander

Martin Simmons martin at lispworks.com
Mon Jun 13 10:56:57 UTC 2011


>>>>> On Mon, 13 Jun 2011 06:50:37 +0000, Julian Squires said:
> 
> Hi,
> 
> On Fri, Jun 10, 2011 at 3:35 PM, Martin Simmons <martin at lispworks.com> wrote:
> > The setf expander for internal-symbol-macrolet makes unwarranted assumptions
> > about the getter form (that it can be used with setf).  Ironically, this setf
> > expander itself returns a form that would fail if used like that!
> 
> This looks reasonable.  Could you supply a test case that breaks the
> earlier definition?  Otherwise it may take me a few days to get to
> this.

Here is a slightly contrived example.

(defun elt-like (index seq)
  (elt seq index))

(define-setf-expander elt-like (index seq)
  (let ((index-var (gensym "index"))
        (seq-var (gensym "seq"))
        (store (gensym "store")))
    (values (list index-var seq-var)
            (list index seq)
            (list store)
            `(if (listp ,seq-var)
                 (setf (nth ,index-var ,seq-var) ,store)
               (setf (aref ,seq-var ,index-var) ,store))
            `(if (listp ,seq-var)
                 (nth ,index-var ,seq-var)
               (aref ,seq-var ,index-var)))))

(let ((cell (list nil)))
  (anaphora:sor (elt-like 0 cell) (setf anaphora:it 1))
  (equal cell '(1)))

Regards,

Martin Simmons
LispWorks Technical Support
http://www.lispworks.com/support/




More information about the anaphora-devel mailing list