<div class="gmail_quote">On 13 April 2011 14:36, Steven Schveighoffer <span dir="ltr"><<a href="mailto:schveiguy@yahoo.com">schveiguy@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, 12 Apr 2011 18:00:40 -0400, spir <<a href="mailto:denis.spir@gmail.com" target="_blank">denis.spir@gmail.com</a>> wrote:<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 04/12/2011 11:51 PM, Steven Schveighoffer wrote:<br>
</div><div><div></div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, 12 Apr 2011 17:21:57 -0400, spir <<a href="mailto:denis.spir@gmail.com" target="_blank">denis.spir@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 04/12/2011 09:21 PM, Steven Schveighoffer wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
int main(){<br>
int a,b;<br>
do{<br>
scanf("%d %d",&a,&b);<br>
}while(a<b) //note missing semicolon here<br>
return 0;<br>
}<br>
<br>
The grammar specifies this correctly, but then again, the example uses the<br>
semicolon. (<a href="http://www.digitalmars.com/d/2.0/statement.html#DoStatement" target="_blank">http://www.digitalmars.com/d/2.0/statement.html#DoStatement</a>)<br>
[...]<br>
I think the grammar should be changed...<br>
</blockquote>
<br>
yop!<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is almost as bad as go's<br>
requirement for if statement opening block to be on the same line...<br>
</blockquote>
<br>
why? I like Go's syntactuc diffs. (except for its "multi-for")<br>
</blockquote>
<br>
in Go, this:<br>
<br>
if(x)<br>
{<br>
gosWriteRoutineThatIDontKnowTheSyntaxOf("hello")<br>
}<br>
<br>
is equivalent to this in D:<br>
<br>
if(x)<br>
{<br>
}<br>
<br>
writeln("hello");<br>
<br>
This is frankly unforgivable IMO.<br>
<br>
Of course it's fixable, but the attitude that "the coder should know better"<br>
doesn't really make me comfortable with it. And I hate the "brace on the same<br>
line" format (but this of course is not a real argument against it).<br>
</blockquote>
<br></div></div><div class="im">
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 '{').<br>
</div></blockquote>
<br>
No, it doesn't enforce anything.  The above compiles and runs.  What it does is introduce subtle bugs.<br>
<br>
The way to fix it is to make the above an error.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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 ;-)<br>
</blockquote>
<br></div>
I know that if(xyz); is not *ever* what I meant, but in C it compiles.  However, in D, it tells me I shouldn't do that.  What results is less bugs because I can't make that mistake without the compiler complaining.<br>

<br>
I'm not saying that the spec isn't well defined, or the manual isn't clear, what I'm saying is, the attitude reflected in the rule is that greater burden is put on the developer to make sure they follow the rules without compiler enforcement.  It makes me want to not use Go.  And in fact, I will probably never use it as long as this rule is in place.<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Maybe, if not done already, a line starting with an opening brace should generate a parsing error.<br>
</blockquote>
<br></div>
Typically this is used to create a new scope in C/D/Java/C#.  This allows declaring temporary variables, not sure how it is in Go, but I'd assume something similar.<br>
<br>
-Steve<br>
</blockquote></div><br><br><div>Does D throw an error at; if(expression && expression)<b>; </b>or only at if(expression);</div><div>Because you could actually use the first one, alike this:</div><div><div><code></div>
<div>#include <stdio.h></div><div><br></div><div>bool test()</div><div>{</div><div>    printf("test\n");</div><div>    return false;</div><div>}</div><div><br></div><div>bool test2()</div><div>{</div><div>
    printf("test2\n");</div><div>    return true;</div><div>}</div><div><br></div><div>int main()</div><div>{</div><div>    if(test() && test2());</div><div>}</div></div><div></code></div><div>Output = "test"</div>
<div>if test returns true, then: Output = "test" + "test2"</div><div><div><br></div><div>Simply because its conditional, and if the first one fails, why bother evaluating the rest?<br clear="all"><br>-- <br>
// Yours sincerely<br>// Emil 'Skeen' Madsen<br>
</div></div>