Re: [PATCH] Fix broken defsetf for places with keywords.
Sam Steingold <[email protected]> Fri, 28 Jun 2019 10:57:12 -0400
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Kaz, Sorry about not replying earlier - I thought that you were actually planning to work more on your patch. > * Kaz Kylheku <[email protected]> [2019-03-01 16:45:18 -0800]: > > Note the code is not prepared to deal with situations when the > keywords are given by evaluated expressions. I am not fixing that > aspect of it, and it's probably a bad idea; a virtue of the defsetf > logic over keyword arguments is that it understands keyword > arguments. How do other implementations handle this? It is unclear if this aspect _can_ be easily fixed. Both CLISP and SBCL fail identically: ``` (defparameter *xy* (make-array '(10 10) :initial-element NIL)) (defun xy-s (&key ((x x) 0) ((y y) 0)) (aref *xy* x y)) (defun xy-k (&key (x 0) (y 0)) (aref *xy* x y)) (defun set-xy-s (new-value &key ((x x) 0) ((y y) 0)) (setf (aref *xy* x y) new-value)) (defun set-xy-k (new-value &key (x 0) (y 0)) (setf (aref *xy* x y) new-value)) (defsetf xy-s (&key ((x x) 0) ((y y) 0)) (store) `(set-xy-s ,store 'x ,x 'y ,y)) (defsetf xy-k (&key (x 0) (y 0)) (store) `(set-xy-k ,store :x ,x :y ,y)) (assert (eql NIL (xy-k :x 1))) (assert (eql NIL (xy-s 'x 1))) (assert (eql 10 (setf (xy-k :x 1) 10))) (assert (eql 20 (setf (xy-s 'x 2) 20))) (assert (eql 20 (xy-k :x 20))) (assert (eql 10 (xy-s 'x 10))) (let ((a 'x) (b 'y)) (setf (xy-s a 1 b 2) 3) (setf (xy-s b 5 a 9) 14)) (assert (eql 3 (xy-s 'y 2 'x 1))) (assert (eql 3 (xy-k :y 2 :x 1))) (assert (eql 14 (xy-k :x 9 :y 5))) (assert (eql 14 (xy-s 'x 9 'y 5))) (setf (xy-k (if t :x :y) 44 (if nil :x :y) 22)) ``` what about others? Does your patch make CLISP support the `LET` form above? Thanks. -- Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1671 http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com http://memri.org http://mideasttruth.com http://iris.org.il http://camera.org The program isn't debugged until the last user is dead. _______________________________________________ clisp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/clisp-list