home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!ames!data.nas.nasa.gov!taligent!apple!cambridge.apple.com!bill@cambridge.apple.com
- From: bill@cambridge.apple.com (Bill St. Clair)
- Newsgroups: comp.lang.lisp.mcl
- Subject: Re: Apply
- Message-ID: <9208121750.AA04124@cambridge.apple.com>
- Date: 12 Aug 92 18:52:59 GMT
- Sender: info-mcl-request@cambridge.apple.com
- Lines: 34
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
- Full-Name: Bill St. Clair
- Original-To: owens@cs.uchicago.edu
- Original-Cc: info-mcl
-
- >From: owens@cs.uchicago.edu
- >Date: Wed, 12 Aug 92 11:59:16 CDT
- >To: bill@cambridge.apple.com
- >Subject: Re: Apply
- >Newsgroups: comp.lang.lisp.mcl
- >Organization: Dept of Computer Science, The Univ of Chicago
- >Cc:
- >
- >In article <9208121537.AA03113@cambridge.apple.com> you write:
- >
- >>[...]
- >>
- >>(defun make-menu-items (items)
- >> (let (menu-items)
- >> (dolist (item items)
- >> (push (make-instance ...
- >> :attached-function
- >> #'(lambda (window)
- >> (declare (ignore window))
- >> (print item)))
- >> menu-items)
- >> ...)))
- >>
- >
- >
- >Bill, I almost posted this exact code fragment, but then I thought of
- >the buggy code that Rao posted the other day, and I couldn't remember
- >whether dolist was guaranteed to create a fresh binding for each
- >iteration. Does your code create an :attached-function that, for each
- >of the menu items, prints the value taken on by ITEM during the last
- >iteration of the DOLIST?
-
- As pointed out by Kim Barrett and Bob Cassells, my code is wrong.
- You need to create a fresh binding or use a mapping function.
-