[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Needs Lisp a front-end?

William James

12/29/2015 11:30:00 PM

Rob Warnock wrote:

> Pascal Costanza <p...@p-cos.net> wrote:
> +---------------
> | The general structure of a DO form is this:
> |
> | (do ((var1 init1 expr1)
> | (var2 init2 expr2)
> | ...)
> | (predicate [result])
> | body ...)
> |
> | This is equivalent to the following LOOP form:
> |
> | (loop for var1 = init1 then expr1
> | for var2 = init2 then expr2
> | ...
> | until predicate
> | ; or:
> | when predicate return result
> | do body ...)
> |
> | There is no real difference...
> +---------------
>
> Incorrect. These two are actually *semantically* different!!
> To make them the same, you need to use AND instead of all but
> the first FOR:
>
> (loop for var1 = init1 then expr1
> AND var2 = init2 then expr2
> ...
> when predicate return result
> do body ...)
>
> Alternatively, you could have used your "all FORs" version
> of the LOOP but replaced DO by DO*, then they would have also
> been the same [but still different from the other DO/LOOP pair].
>
> +---------------
> | Compare:
> | (loop for var1 in list1
> | for var2 = init2 then expr2
> | for index from 0
> | do body ...)

MatzLisp (Ruby):

var2 = 2
%w(a b c d).each_with_index{|var1,index|
p [index, var1, var2]
var2 *= 10}

[0, "a", 2]
[1, "b", 20]
[2, "c", 200]
[3, "d", 2000]


> |
> | with:
> | (do ((tail1 list1 (cdr tail1))
> | (var2 init2 expr2)
> | (index 0 (1+ index))
> | ((null tail1))
> | (let ((var1 (car tail1)))
> | body ...))
> +---------------
>
> Again these are different: You need to either (1) use DO* for the
> second or (2) in the LOOP replace all FOR except the first with AND.
> Warning: (1) & (2) can give different results, depending upon the
> form EXPR2!!

Worshippers of CL (COBOL-Like) and LOOP are clueless.

--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunk...
https://www.youtube.com/watch?v=E...