[CM] CM's loop macro, issues/incompleteness of implementation?

Iain Duncan iainduncanlists at gmail.com
Sun Apr 19 08:01:44 PDT 2020


Ok now this is making sense, for some reason Orm's message went to my spam
bin. Sorry for the confusion.

Thanks Orm, I'll look through the various places you recommended.

iain

On Sun, Apr 19, 2020 at 12:52 AM Orm Finnendahl <
orm.finnendahl at selma.hfmdk-frankfurt.de> wrote:

> Hi Iain,
>
>  some of the differences out of my head:
>
> - no argument destructuring like
>
>   (loop for (x y . rest) on seq
>         while y
>         do (display (format "~a~%" (cons (+ x y) rest))))
>
> - no array traversal like
>
>   (loop for x across my-array do (display (format "~a~%" x))
>
> - no hash table traversal like
>
>   (loop for k
>         being the hash-key
>         using (hash-value v) of h
>         do (display (format "~a ~a~%" k v)))
>
> There are more things loop provides which weren't considered essential
> or even useful in the context of a process. IIRC things like
> "collect", "append" or "into" aren't present. To assemble a complete
> list check the loop chapter in cltl2 here:
>
>
> https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node235.html#SECTION003000000000000000000
>
> More importantly there are bugs in the code when variables reference
> each other like this:
>
> (sprout
>  (process
>    for a in '(0 1 2)
>    for b = a then (+ a 1)
>    do (display (format "a: ~a, b: ~a~%" a b))))
>
> -> a: 0, b: #f
> -> a: 1, b: 1
> -> a: 2, b: 2
>
> The expected output would be:
>
> -> a: 0, b: 0
> -> a: 1, b: 2
> -> a: 2, b: 3
>
> I fixed it in the CL code base in my github repository of CM. It
> shouldn't be too difficult to translate that into scheme.
>
> With the current code base I think it's a good idea to advise users
> against cross referencing variables in the initialization and updating
> phase of the process form.
>
> --
> Orm
>
>
> Am Samstag, den 18. April 2020 um 18:53:29 Uhr (-0700) schrieb Iain Duncan:
> > Hi everyone, there was a comment a while back that the loop macro
> provided
> > by the CM scheme code is not a perfect implementation of CL's loop. I'd
> > like to use it in Scheme for Max, but as I don't know either CL or CM
> well,
> > can anyone tell me more about where this diverges or doesn't implement
> the
> > "normal" CL loop macro? I want to make sure I document this properly for
> > users coming from CL.
> >
> > thanks
> > iain
>
> > _______________________________________________
> > Cmdist mailing list
> > Cmdist at ccrma.stanford.edu
> > https://cm-mail.stanford.edu/mailman/listinfo/cmdist
>
> _______________________________________________
> Cmdist mailing list
> Cmdist at ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/cmdist
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20200419/3ff81f6a/attachment.html>


More information about the Cmdist mailing list