[bitc-dev] Error in specification of DO
david.hopwood at industrial-designers.co.uk
Wed Jul 9 18:53:59 CDT 2008
Valerio Bellizzomi wrote:
> 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
>>> WHILE perform body while test remains true
>>> WHILE-NOT perform body while test remains false
>>> DO-UNTIL perform body until test becomes true, running at least
>>> 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 agree. I also think that something equivalent to C's 'break'
(as used to break from a loop) and 'continue' are needed.
However, I would seriously consider *requiring* Java-style labelled
break and continue, without any default for which loop is referred to.
More information about the bitc-dev