Re: do expression
- From: Barry Margolin <barmar@xxxxxxxxxxxx>
- Date: Tue, 01 Jan 2008 17:41:31 -0500
In article <5tvjleF1f4c0hU1@xxxxxxxxxxxxxxxxxx>,
Pascal Costanza <pc@xxxxxxxxx> wrote:
Barry Margolin wrote:
In article <5tup2mF1fa6d1U2@xxxxxxxxxxxxxxxxxx>,
Pascal Costanza <pc@xxxxxxxxx> wrote:
William D Clinger wrote:
Pascal Costanza wrote:What would be an example of an iteration that requires binding semantics
Yes, it is generally equivalent....The transformation you illustrated does not work in general.
Getting from one version to the other requires only strictly local
changes.
that cannot be easily expressed in an iteration construct with
side-effecting semantics? I have a hard time coming up with anything
useful here...
If you create a closure during the loop, and expect it to remember the
value of the iteration variable from that cycle, you need binding
semantics.
That's what I have done in my loop example, and it seems pretty
straightforward to me:
(loop for x from 0 below 10
collect (let ((x x)) (lambda () x)))
If this doesn't work in general, when does it not work?
Yes, it works. But it forces you to do an extra let, which introduces
no real variables, when the original looping macro could have bound the
variable for you in the first place.
--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.
- Follow-Ups:
- Re: do expression
- From: Pascal Costanza
- Re: do expression
- References:
- Re: do expression
- From: Pascal Costanza
- Re: do expression
- From: Barry Margolin
- Re: do expression
- From: Pascal Costanza
- Re: do expression
- Prev by Date: Re: do expression
- Next by Date: Re: do expression
- Previous by thread: Re: do expression
- Next by thread: Re: do expression
- Index(es):
Relevant Pages
|