Errors in TDPL

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Jun 22 14:37:59 PDT 2010


On 06/22/2010 04:14 PM, Jonathan M Davis wrote:
> Andrei Alexandrescu wrote:
>
>> On 06/21/2010 03:32 PM, Ellery Newcomer wrote:
>>> I was biting my tongue on the subject, but on page 73 the grammar for
>>> the do while loop has a semicolon at the end. AAHHHHHHHHHHHHH!!!!!!!!
>>> THERE IS NOOOOOOO SEMICOLON AT THE END.
>>>
>>> Wow. Sorry. This is a pet peeve of mine.
>>
>> Can't help that, sorry...
>>
>> Andrei
>
> Well, while I, personally, would put a semicolon there (it feels naked to me
> without one), dmd doesn't actually seem to require it. But TDPL says that
> the semicolon is required. So, it does appear to be an error in the text. Of
> course, there's no helping his pet peeve regardless, but the semicolon
> doesn't appear to be required.
>
> - Jonathan M Davis

Walter, was that intentional? The grammar has no semicolon but the 
example does. That makes the example wrong because you agreed there is 
no solitary semicolon statement in D, and TDPL does mention that.

IMHO the semicolon makes for more robust code. Consider:

do
{
     ... lotsa code ...
}
while (fun(i))
++i;

A maintainer might see the while and conclude that ++i; was meant to be 
the loop, indent it, and call it a day. The absence of the semicolon 
thus created a contextual dependency on the presence of the "do" keyword 
upstream.

Walter, can we require a semicolon please?


Andrei


More information about the Digitalmars-d mailing list