Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!cme!cam!ARTEMIS From: miller@cam.nist.gov (Bruce R. Miller) Newsgroups: comp.lang.lisp Subject: Re: Constants in code (Ex- Virtues of Lisp syntax) Message-ID: <2863191137@ARTEMIS.cam.nist.gov> Date: 24 Sep 90 18:52:17 GMT References: Sender: news@cam.nist.gov Followup-To: comp.lang.lisp Organization: NIST - Center for Computing and Applied Mathematics Lines: 60 In article , David Vinayak Wallace writes: > Date: 21 Sep 90 22:09:56 GMT > From: miller@GEM.cam.nist.gov (Bruce R. Miller) > Larry Masinter wrote: > > (let ((var '(a b c))) > > ... > > (nconc var value)) > ... > In any case, one could imagine a perfectly legitimate interpretter > consing the list fresh every time, giving a 3rd behavior. Before you > groan, consider that this might in fact be the most consistent behavior! > The (QUOTE (A B C)) form is (conceptually, at least) evaluated each time > the function is called! Should (QUOTE (A B C)) sometimes > return (A B C FOO)? > > The interpretation of either case is straightforward. > > Quote returns the object it was handed. It doesn't try to guess "what > you meant." After all, the code isn't text; quote just has a pointer > to the car of the list you handed it! > I'm a little confused about what you're saying. In the simplest case, READ consed up the list, and QUOTE just returns its arg. Clearly if you repeatedly INTERPRETED the above form, you get the same result each time. (but perhaps not within a defun which may or may not digest the form!) Compilation makes it a bit less clear; READ is no longer involved. What pointer are we handing it? If you WANT the permanent change then you should presumably write (let ((var '(a b c))) (defun foo (..) .. (nconc var value))) to make clear the extent of var. > I would be unhappy if quote performed computation each time you used > it! A very common idiom is to pass a quoted, uninterned symbol around > as a marker in some structure. (I used to use '(())). This is the > only way I can get a token I guarantee won't appear in my input > stream! > So would I!!!! I dont quite follow your example, but I'm certainly not suggesting that quote should creates a new list -- nor even that the (a b c) should be consed anew each time. Indeed, I expect the quote should `disappear' upon compilation. I just wanted to say that the EFFECT of that approach MAY be the most appropriate behavior. > Anyway, the capability to side-effect constants in storage was not > removed for taste reasons, but efficiency; it permits me as a lisp > implementor to place code into read-only storage (and possibly share > it among processes). Ah, if it's in read-only storage then you can NOT modify it, no? BTW; Tim Moore, in another posting pointed out that this is considered `illegal' although he didn't say if CLtL specified whether an error is signalled or whether it is simply `undefined'. bruce