Xref: utzoo comp.lang.lisp:4919 comp.lang.scheme:2546 comp.sources.wanted:16786 Newsgroups: comp.lang.lisp,comp.lang.scheme,comp.sources.wanted Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!barmar From: barmar@think.com (Barry Margolin) Subject: Re: SETF of LET Message-ID: <1991May22.180507.4914@Think.COM> Sender: news@Think.COM Reply-To: barmar@think.com Organization: Thinking Machines Corporation, Cambridge MA, USA References: <1991May20.201244.21948@uicbert.eecs.uic.edu> <1991May22.072355.22077@kestrel.edu> Date: Wed, 22 May 91 18:05:07 GMT In article <1991May22.072355.22077@kestrel.edu> gyro@kestrel.edu (Scott Layson Burson) writes: >I have just come to the conclusion, after trying for several hours, >that it is not possible to write a SETF method for LET using >DEFINE-SETF-METHOD. You might want to check with the Master Macrologist, Alan Bawden. If it can be done, he can probably figure out how to do it. If it can't, he can probably prove it. > (define-setf-method let (clauses &rest body) > (let ((storevar (gensym))) > (values '() '() (list storevar) > `(let ,clauses > ,@(butlast body) > (setf ,(car (last body)) ,storevar) > (car (last body)))))) > >So, roughly speaking, (setf (let ((x ...)) (car x)) 'foo) turns into >(let ((x ...)) (setf (car x) 'foo)). > >The problem with the definition above is that it potentially evaluates >the subforms of the last form in the body more than once; so Could the problem be that you're expanding into another SETF, rather than using GET-SETF-METHOD-MULTIPLE-VALUE on (car (last body))? If the last form in the body needs special attention like this, its SETF expansion should take care of it. >So I'm surprised that CLtL2 doesn't specify (at least not that I've >been able to find) that SETF of LET should work. Is this perhaps >simply an oversight, that should be brought to the attention of X3J13? I think it's just an oversight by the original SETF designers in MacLisp, which the CL SETF is basically a clone of. You can bring it to our attention, but I don't think anything will come of it in the near future, as it's too late to add something significant like this to the language. -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar