Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #29: It works the way the Wang did, what's the problem


comp / comp.lang.lisp / Re: Slow Loop (alternatives in lisp?)

SubjectAuthor
* Re: Slow Loop (alternatives in lisp?)B. Pym
+- Re: Slow Loop (alternatives in lisp?)Kaz Kylheku
`- Re: Slow Loop (alternatives in lisp?)steve g

1
Subject: Re: Slow Loop (alternatives in lisp?)
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Mon, 22 Jul 2024 18:29 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: Slow Loop (alternatives in lisp?)
Date: Mon, 22 Jul 2024 18:29:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 126
Message-ID: <v7m8d9$p1e4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Mon, 22 Jul 2024 20:29:17 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9bd2863663604f2e05c19a8ebb644b33";
logging-data="820676"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1860Q3Xw1Vj0rnb8s9mZKUn"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:J4k+nH+rTwnqxgCNK7/bf01qV50=
View all headers

> * there is already a WHILE in Common Lisp. No need to invent a new one:
>
> (loop while (foo-p) do .... )

Gauche Scheme

(while (read) (print "True enough."))
2 True enough.
#t
True enough.
'yes
True enough.
#f

(while (read) => x (print x " is truer than you think."))
"why"
why is truer than you think.
88
88 is truer than you think.
0 0 is truer than you think.
#f

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:

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.

> 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!

John Foderaro:

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.

....

Another great example from kmp:

=== from kmp

For example, you might think
(loop with i = (random 100) for x from 1 to 10 do (print (list i x)))
and
(loop for i = (random 100) for x from 1 to 10 do (print (list i x)))
meant the same in English, [but they don't do the same thing in loop]

=== end kmp

loop lulls you into thinking that you understand the program since
you understand English. Make no mistake about it, loop is its
own language. If you use it you condem everyone who reads the
code to also learn the loop language.

Subject: Re: Slow Loop (alternatives in lisp?)
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 23 Jul 2024 01:24 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: Slow Loop (alternatives in lisp?)
Date: Tue, 23 Jul 2024 01:24:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <20240722182106.323@kylheku.com>
References: <v7m8d9$p1e4$1@dont-email.me>
Injection-Date: Tue, 23 Jul 2024 03:24:37 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2e723cea1cdfb5e1d326eb8834436c3e";
logging-data="950529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5mqGKzRLyuG5g5vw23DXH/lrOrTolJ7I="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:jeFOci+X1/nfmsDcVID9UfIj6ZE=
View all headers

On 2024-07-22, B. Pym <Nobody447095@here-nor-there.org> wrote:
>> * there is already a WHILE in Common Lisp. No need to invent a new one:
>>
>> (loop while (foo-p) do .... )
>
> Gauche Scheme
>
> (while (read) (print "True enough."))
> 2
> True enough.
> #t
> True enough.
> 'yes
> True enough.
> #f
>
> (while (read) => x (print x " is truer than you think."))
[ ... ]
> 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.

But the above => cruft is exactly like LOOP clause syntax.

It might as well be

(while (read) with x do (print ...))

More Lispy way:

(whilet ((x (read)))
...)

Subject: Re: Slow Loop (alternatives in lisp?)
From: steve g
Newsgroups: comp.lang.lisp
Date: Sat, 10 Aug 2024 18:09 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 10 Aug 2024 18:10:00 +0000
From: sgonedes1977@gmail.com (steve g)
Newsgroups: comp.lang.lisp
Subject: Re: Slow Loop (alternatives in lisp?)
References: <v7m8d9$p1e4$1@dont-email.me>
Date: Sat, 10 Aug 2024 14:09:54 -0400
Message-ID: <877ccofdvx.fsf@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:k3IBjQt0cgYPoK/U45DuYvcbHxo=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 149
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-6X6Vx8Isq6QoYppEygCKaYCO3fV0QzbCKXByz1XBeshGQnVmtV9+naHJvDyLL6GyuCa0mD3TULlCVvU!o4s9Ye0Ekn0aAZyk/PQSkCnChHfEbXf7baSZkHbrJ14080w=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

"B. Pym" <Nobody447095@here-nor-there.org> writes:

< > * there is already a WHILE in Common Lisp. No need to invent a new one:
< >
< > (loop while (foo-p) do .... )
>
> Gauche Scheme
>
> (while (read) (print "True enough."))
> 2
> True enough.
> #t
> True enough.
> 'yes
> True enough.
> #f
>
> (while (read) => x (print x " is truer than you think."))
> "why"
> why is truer than you think.
> 88
> 88 is truer than you think.
> 0
> 0 is truer than you think.
> #f
>
>
>
>
> Paul Graham:

> ....
> the ANSI standard does not really give a formal specification
> of its behavior.
> ....

not an ANSI issue; it is a machine issue. you cannot add new registers
to a CPU.

> 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.
> ....

i hope you are not talking about order of evaluation - this is a scheme
problem; not with common lisp.

> For such reasons, the use of loop cannot be recommended.

it works, it is repeatable, and it is predictable. I typically use loop
that came from MIT lisp machine.
>
> 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:
>
> 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.
>
< > 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,

have you ever tried programming in PERL or assembler?

>
> John Foderaro:
>
> 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 would consider the condition system and format macros to be more
complicated. You need to use a quick cheat sheet. not too hard.

> 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.

1986 was a long time ago. why not reinvent a language that has call/cc!

>
> ...
>
> Another great example from kmp:
>
> === from kmp
>
> For example, you might think
> (loop with i = (random 100) for x from 1 to 10 do (print (list i x)))

> and
> (loop for i = (random 100) for x from 1 to 10 do (print (list i x)))
> meant the same in English, [but they don't do the same thing in loop]

using `with' in a loop clause allows one to use variables.

>
> === end kmp
>
> loop lulls you into thinking that you understand the program since
> you understand English. Make no mistake about it, loop is its
> own language.

> If you use it you condem everyone who reads the
> code to also learn the loop language.

why the hatred of iteration? i can already tell that you are a scheme
programmer. anything that is not tail recursive is evil for some reason.
I did understand this.

the biggest problem with loop is implementing it.

1

rocksolid light 0.9.8
clearnet tor