[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: LOOP blows!

William James

1/7/2016 10:26:00 AM

Ken Tilton wrote:

> Kaz Kylheku wrote:
> > On Feb 7, 6:35 pm, Maciej Katafiasz <mathr...@gmail.com> wrote:
> >
> >>Den Thu, 07 Feb 2008 17:48:59 -0800 skrev Kaz Kylheku:
> >>
> >>
> >>>>That is an impressive way to say NIL, but I'm somewhat disappointed
> >>>>that it's not a quine.
> >>>>Can we expect version Final.1 to fix that bug?
> >>
> >>>Nope, works on my machine. Your LOOP is obviously broken. :)
> >>
> >>>Does this return (1 2 3)?
> >>
> >>> (loop for x = '(1 2 3) for y in x do collect y)
> >>
> >>A compound form was expected, but collect found.
> >
> >
> > Oops,
>
> Oops? Ooops?!!! I spend 300,000 miiliseconds out of what little remains
> of my life on a cut and paste error and all you can say is frickin oops?
> Well, as long as you do not...
>
> > Try:
>
> Turn loose the hounds.
>
> >
> > (loop for x = '(1 2 3) for y in x collect y)
>
> Why are you exploring deliberately retarded forms in a DSL? Now y'all
> know why I gotta get outtahere.
>
> >
> > If that yields NIL, it shows that the broken LOOP isn't propagating
> > the '(1 2 3) from the first FOR to the second.
> >
> > If it was for x = '(1 2 3) AND y in x then it would make sense.
> > The previous value of X is NIL in the first iteration, and so Y gets
> > that.
> >
> >
> >>> (loop for x = '(1 2 3)
> >>> for y in x
> >>> for z = y
> >>> for w = y
> >>> collect w)
> >>
> >>This one gives NIL. SBCL 1.0.10 (I guess I should rebuild a newer version
> >>one of these days).
> >
> >
> > Maybe the workaround is to change the first FOR to a WITH.
>
> Ok, help me here. You concede now that you haven't the slightest clue
> about LOOP and you are trying to preach to us and telling us to run
> stuff to see what it does in our implementations when you are just
> publishing the droolings of a newborn??!!! Jeez...
>
> Well, you do get points for calling the correction of your asinity a
> "workaround" -- frickin priceless -- Google knows I love a fine brass pair.
>
> "Workaround"?????????????? PWUAHAHAHAHHHAHHAHAHAH.
>
> 2+2=5
>
> Hang on, I have a workaround: 4. Whew! Gotta be a genius prize in there
> for that save!
>
> > See, nobody
> > should use FOR this way; I intended a variable initialization, not a
> > repeated assignment of the same value to the variable on each
> > iteration.
>
> You are the man! You seamlessly turn your ignorance into a lecture
> series on how loop works! See, nobody should be as dense as me...
>
> Meanwhile, a simple "Oh, cripes, my bad. What a 'tard. Sorry for the
> noise." would have endeared you to everyone. I would have unleashed the
> hounds and they'd be licking your face!
>
> >
> > (LOOP WITH AND =
> > '(LOOP WITH AND = '(LOOP WITH AND = DNA) FOR WITH IN AND FOR = = AND
> > FOR
> > FINALLY = WITH COLLECT FINALLY INTO IF FINALLY
> > (RETURN
> > (LOOP FOR IN IN IF WHEN (EQUAL IN ''(LOOP WITH AND = DNA)) COLLECT
> > (LIST 'QUOTE AND) ELSE COLLECT IN)))
> > FOR WITH IN AND FOR = = AND FOR FINALLY = WITH COLLECT FINALLY INTO
> > IF FINALLY
> > (RETURN
> > (LOOP FOR IN IN IF WHEN (EQUAL IN ''(LOOP WITH AND = DNA)) COLLECT
> > (LIST 'QUOTE AND) ELSE COLLECT IN)))
>
> Boy. No wolf. Please note unresponsiveness.


Paul Graham:

I consider Loop one of the worst flaws in CL, and an example
to be borne in mind by both macro writers and language designers.


[ In "ANSI Common Lisp", Graham makes the following comments: ]

The loop macro was originally designed to help inexperienced
Lisp users write iterative code. Instead of writing Lisp code,
you express your program in a form meant to resemble English,
and this is then translated into Lisp. Unfortunately, loop is
more like English than its designers ever intended: you can
use it in simple cases without quite understanding how it
works, but to understand it in the abstract is almost
impossible.
....
the ANSI standard does not really give a formal specification
of its behavior.
....
The first thing one notices about the loop macro is that it
has syntax. A loop expression contains not subexpressions but
clauses. The clauses are not delimited by parentheses;
instead, each kind has a distinct syntax. In that, loop
resembles traditional Algol-like languages. But the other
distinctive feature of loop, which makes it as unlike Algol as
Lisp, is that the order in which things happen is only
loosely related to the order in which the clauses occur.
....
For such reasons, the use of loop cannot be recommended.



-----


Dan Weinreb, one of the designers of Common Lisp:

.... the problem with LOOP was that it turned out to be hard to
predict what it would do, when you started using a lot of
different facets of LOOP all together. This is a serious problem
since the whole idea of LOOP was to let you use many facets
together; if you're not doing that, LOOP is overkill.


-----


Barry Margolin, 05 Apr 2001
(http://groups.google.com/group/comp.lang.lisp/msg/8a48ce...)

>(My second rule of thumb concerning LOOP would be the negative of
>Barry Margolin's: The more complex the looping, the more you need/want
>to use LOOP.)

My recommendation is based on seeing many question in the past of the form
"What happens if you use both XXX and YYY in the same LOOP?" The
unfortunate fact is that when we were writing the standard we didn't have
time to nail down all the possible interactions between different LOOP
features, so many of these are not well specified. And even if we did get
it right in the standard, it's likely to be difficult to find them and I
wouldn't trust that all implementors got it right (many of those questions
were probably from implementors, trying to figure out what they were
supposed to do). And even if they all got it right, someone reading your
code may not be able to figure it out.

So, with all those potential problems, my feeling is that if you have to
ask, it's probably better to use something other than LOOP.


-----

Barry Margolin:

> 3. Loop is very powerful, granted, and many people are trying to
> argue that "you can do so much with loop that it's unreadable."
> This is not an argument.

But it is! Because any use of LOOP has the potential to be
unreadable, the reader must read it carefully to verify that
it's just one of the cases that doesn't require careful
reading!

-----

Barry Margolin: (05 Apr 2002 20:57:48 GMT)

This seems like a big change just to clean up the way LOOP is described.
And LOOP will still be a wart, because it will be the only language feature
that uses "per-macro keywords". Providing this interface and giving a name
to them would encourage other macro designers to do something similar, and
we don't want more things like LOOP.


-----

Re: Bad Idiom?

Barry Margolin (1997-01-08)

There are a few things that can be done extremely conveniently
with LOOP, and I will usually use LOOP in those cases. In
particular, the COLLECTING feature is one of the most
convenient.

The Generators and Collectors macros described in Appendix B
of CLtL2 also provide this convenience and are much more
Lisp-like. It's too bad they weren't around when LOOP was
gaining popularity, and I think they're a better way to go.
But LOOP is what I got used to, and its popularity is why it
got elevated into the ANSI standard.


-----

From: John Foderaro <jkf@unspamx.franz.com>
Newsgroups: comp.lang.lisp
Subject: Re: the "loop" macro
Date: Sun, 26 Aug 2001 10:51:26 -0700

I'm not trying to join a debate on loop. I just wanted to present
the other side of [the issue so that] the intelligent people can
then weigh the arguments on both sides.

I'm not suggesting that loop can be fixed either by adding
parenthesis or coming up with ways of indenting it to make it
understandable. It's a lost cause.


--
"If a government uses the instruments of power in its hands for the purpose of
leading a people to ruin, then rebellion is not only the right but also the
duty of every individual citizen."