[plt-scheme] (newbie question) About Loop

From: namekuseijin (namekuseijin at gmail.com)
Date: Fri Jun 12 16:47:14 EDT 2009

I've seen this discussion before...

http://groups.google.com/group/comp.lang.scheme/msg/e3643edd67abf508

On Fri, Jun 12, 2009 at 4:56 PM, Neil Van Dyke<neil at neilvandyke.org> wrote:
>
>> straightforward, standard and with no intermediary list building:
>>
>> (do ((i 0 (+ 1 i)))
>>
>
> "do" is standard for now, but I dream that we will someday right that wrong.
>  "do" is a cryptic bit of syntactic sugar that gets in the way of refining
> functional algorithms.
>
> Instead of "do", I suggest using named-"let" unless "map", "for-each",
> folds, etc. fit the problem naturally.

Fact is:  do *is* named let, only more convenient and a bit more limited.

> I think that the benefit of avoiding "do" will be more obvious when writing
> idiomatic Scheme code for problems that actually occur in nature, not
> contrived exercises (like, e.g., "do this 7 times for no particular reason
> and with no data being processed").

The guy wanted a simple loop and simple loops are pretty common in
everyday programming.  do fits the bill just nicely and without fuss,
rather than requiring him to manually name a loop and explicitly call
it recursively.  I hope that right is not wronged. :)


Posted on the users mailing list.