On Tue, 12 Apr 2011 14:57:26 -0400, Timon Gehr <timon.g...@gmx.ch> wrote:
I just noticed a little oddity.
Why does this code compile? The equivalent C code is rejected:
import std.stdio;
//#include <stdio.h>
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)
That looks horrible, reformatted looks even worse:
int main()
{
int a,b;
do
{
scanf("%d %d",&a,&b);
}
// so here is a comment to separate things a bit
//
// do you think this makes sense?:
while(a<b)
return 0;
}
I think the grammar should be changed... This is almost as bad as go's
requirement for if statement opening block to be on the same line (would
be as bad, but do..while doens't occur a lot).
-Steve