Re: do expression



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:
Yes, it is generally equivalent....

Getting from one version to the other requires only strictly local
changes.
The transformation you illustrated does not work in general.
What would be an example of an iteration that requires binding semantics
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 ***
.



Relevant Pages

  • Re: do expression
    ... Pascal Costanza wrote: ... What would be an example of an iteration that requires binding semantics that cannot be easily expressed in an iteration construct with side-effecting semantics? ... 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. ...
    (comp.lang.scheme)
  • Re: [PATCH] Really *do* nothing in while loop
    ... > You guys REALLY do not see the changed semantics here? ... deflatein this case does only ONE iteration. ... So the whole while loop does only ONE iteration, ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: newby Q: iterating over /longest/ of multiple lists
    ... Pascal Costanza wrote: ... >> I see the MAP family always stops at the shortest of multiple lists ... >> soldier on through the longest while binding nil to the other ... >> iteration vars have been rejected all. ...
    (comp.lang.lisp)
  • Re: Relative merits of Lisp-1 vs. Lisp-2?
    ... Pascal Costanza wrote: ... Language design is based on semantics, ...
    (comp.lang.lisp)
  • Re: Relative merits of Lisp-1 vs. Lisp-2?
    ... Pascal Costanza wrote: ... Language design is based on semantics, ... tripped up by unusual syntaxes because they obey stronger laws. ...
    (comp.lang.lisp)