Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!ora!bloom-beacon!dont-send-mail-to-path-lines From: gyro@cymbal.reasoning.COM (Scott Layson Burson) Newsgroups: comp.lang.scheme Subject: SETF of LET Message-ID: <9105232056.AA25432@cymbal.reasoning.com.> Date: 23 May 91 20:56:10 GMT References: <1991May22.134211.13554@hellgate.utah.edu> Sender: daemon@athena.mit.edu (Mr Background) Reply-To: Gyro@reasoning.com Organization: The Internet Lines: 67 Yow! I posted that message to comp.lang.lisp -- had no idea it would show up here. Date: 22 May 91 19:42:11 GMT From: Tim Moore In article <1991May22.180507.4914@Think.COM> barmar@think.com writes: >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. > >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. That's right, but that approach leads to another dead end, for this reason: SETF itself contains a form that looks like `(LET* ,BINDINGS ,STORE-FORM). Any DECLARE forms that were in the original LET need to be moved to the one consed by this backquote expression. However, STORE-FORM, as you see, is singular. If the backquote expression looked like `(LET* ,BINDINGS . ,STORE-FORMS) then it would work, as far as I know, but making STORE-FORMS plural in this way would be an incompatible change to the DEFINE-SETF-METHOD interface. I fooled around a bit with this problem this morning. The bindings of the let probably need to be bound around the accessor form too, so you want to move the let bindings into the vars and vals returned by define-setf-method. BUT define-setf-method has to return gensyms (or gentemps) for its bindings. So you need to augment the environment passed to the inner GET-SETF-METHOD-MULTIPLE-VALUE with symbol-macro bindings that substitute references to the variables of the LET with refs to temporaries. For good measure, you should add new declaration info (with reference to the temporaries) to the environment too. Then wrap LOCALLY around the store and accessor forms, and you're set. Are you sure it's that complicated? See the previous paragraph. >>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. SETF of LET worked in all three variants of ZetaLisp c. 1985. That's when I got used to using it. I can't see that SETF of LET would really be that useful. Unless you make restrict the last form the LET to be a generalized location, which seems very restrictive, you would have to write setf methods for every special form in the language to make this work in the general case. The value comes when I have lots of macros, each of which constructs a generalized variable reference, and when most or all of them expand to LET forms (as is pretty common, since macros should always be careful to bind variables for any subforms whose values are needed in more than one place in the expansion). Yeah, sure, I can define SETF for each one of those macros individually, and that's what I guess I have to do. But as I say, I was spoiled by ZetaLisp ('twas ever thus). -- Scott