Semicolon can be left out after do-while

spir denis.spir at gmail.com
Tue Apr 12 15:00:40 PDT 2011


On 04/12/2011 11:51 PM, Steven Schveighoffer wrote:
> On Tue, 12 Apr 2011 17:21:57 -0400, spir <denis.spir at gmail.com> wrote:
>
>> On 04/12/2011 09:21 PM, Steven Schveighoffer wrote:
>>
>>> int main(){
>>> int a,b;
>>> do{
>>> scanf("%d %d",&a,&b);
>>> }while(a<b) //note missing semicolon here
>>> return 0;
>>> }
>>>
>>> The grammar specifies this correctly, but then again, the example uses the
>>> semicolon. (http://www.digitalmars.com/d/2.0/statement.html#DoStatement)
>>> [...]
>>> I think the grammar should be changed...
>>
>> yop!
>>
>>> This is almost as bad as go's
>>> requirement for if statement opening block to be on the same line...
>>
>> why? I like Go's syntactuc diffs. (except for its "multi-for")
>
> in Go, this:
>
> if(x)
> {
> gosWriteRoutineThatIDontKnowTheSyntaxOf("hello")
> }
>
> is equivalent to this in D:
>
> if(x)
> {
> }
>
> writeln("hello");
>
> This is frankly unforgivable IMO.
>
> Of course it's fixable, but the attitude that "the coder should know better"
> doesn't really make me comfortable with it. And I hate the "brace on the same
> line" format (but this of course is not a real argument against it).

Oh, that's what you meant! I find this a Good Thing, in that it enforces one 
bracing style (the right one, that does not eats one more line for just a '{').
About knowing or not about this (non/mis/-)feature, it's written down, and 
clearly, in all Go docs I've read. And one cannot miss it for very long anyway 
;-) Maybe, if not done already, a line starting with an opening brace should 
generate a parsing error.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list