On 09/07/2008, at 23.16, David-Sarah Hopwood wrote:

>Jonathan S. Shapiro wrote:
>> I have just realized that the specification of DO is not what we
wanted.
>> I followed the Scheme specification of DO here. You will find on the
web
>> statements in various places that Scheme DO implements DO-UNTIL. Those
>> statements are incorrect. What Scheme DO implements is in fact
>> WHILE-NOT. That is: a Scheme DO loop may not perform any executions of
>> the body at all.
>> 
>> I tend to believe that there are good uses for all of the following
>> constructs:
>> 
>>   WHILE       perform body while test remains tr
>>   WHILE-NOT   perform body while test remains false
>>   DO-UNTIL    perform body until test becomes true, running at least
>>               once.
>> 
>> Of the three, I believe that WHILE-NOT is the least commonly useful,
and
>> that it is trivially subsumed by WHILE.
>
>C-family languages have DO..WHILE rather than DO..UNTIL, of course.
>The (small) advantages of this are:
>  - familiarity to C, C++, Java and C# programmers,
>  - changing a loop between the WHILE and DO..WHILE forms does not
>    require inverting the condition.

Whatever it is named, we need a construct that guarantees at least one
execution of the body, because the value of the loop condition is set
inside the body.

>
>I briefly looked at uses of 'do {...} while (condition)' in my C code,
>and it did not seem like "negative" conditions were generally any more
>common than "positive" ones (i.e. that the code would have been made
>clearer by being able to invert the condition).
>
>A minor advantage of DO..UNTIL is that the condition acts as an
>assertion that is true after the loop (rather than false after the
>loop, which might require a reader of the code to mentally invert it
>in more cases). I would consider this to be less important than the
>familiarity issue.
>
>-- 
>David-Sarah Hopwood
>_______________________________________________
>bitc-dev mailing list
>[email protected]
>http://www.coyotos.org/mailman/listinfo/bitc-dev



_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to