Commit a1368a6a authored by Robert Griesemer's avatar Robert Griesemer

go spec: make condition mandatory in if statements

Plus a few minor HTML fixes.

Fixes #1535.

R=r, rsc, ken2, iant, r2
CC=golang-dev
https://golang.org/cl/4185065
parent 52943bfe
...@@ -2744,7 +2744,7 @@ and finally <code>||</code> (logical or): ...@@ -2744,7 +2744,7 @@ and finally <code>||</code> (logical or):
Precedence Operator Precedence Operator
5 * / % &lt;&lt; &gt;&gt; &amp; &amp;^ 5 * / % &lt;&lt; &gt;&gt; &amp; &amp;^
4 + - | ^ 4 + - | ^
3 == != &lt; &lt;= > >= 3 == != &lt; &lt;= &gt; &gt;=
2 &amp;&amp; 2 &amp;&amp;
1 || 1 ||
</pre> </pre>
...@@ -2760,7 +2760,7 @@ For instance, <code>x / y * z</code> is the same as <code>(x / y) * z</code>. ...@@ -2760,7 +2760,7 @@ For instance, <code>x / y * z</code> is the same as <code>(x / y) * z</code>.
x &lt;= f() x &lt;= f()
^a &gt;&gt; b ^a &gt;&gt; b
f() || g() f() || g()
x == y+1 &amp;&amp; &lt;-chan_ptr > 0 x == y+1 &amp;&amp; &lt;-chan_ptr &gt; 0
</pre> </pre>
...@@ -3686,17 +3686,16 @@ complex, or string constant. ...@@ -3686,17 +3686,16 @@ complex, or string constant.
"If" statements specify the conditional execution of two branches "If" statements specify the conditional execution of two branches
according to the value of a boolean expression. If the expression according to the value of a boolean expression. If the expression
evaluates to true, the "if" branch is executed, otherwise, if evaluates to true, the "if" branch is executed, otherwise, if
present, the "else" branch is executed. A missing condition present, the "else" branch is executed.
is equivalent to <code>true</code>.
</p> </p>
<pre class="ebnf"> <pre class="ebnf">
IfStmt = "if" [ SimpleStmt ";" ] [ Expression ] Block [ "else" Statement ] . IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" Statement ] .
</pre> </pre>
<pre> <pre>
if x > 0 { if x &gt; max {
return true; x = max
} }
</pre> </pre>
...@@ -3708,7 +3707,7 @@ executes before the expression is evaluated. ...@@ -3708,7 +3707,7 @@ executes before the expression is evaluated.
<pre> <pre>
if x := f(); x &lt; y { if x := f(); x &lt; y {
return x return x
} else if x > z { } else if x &gt; z {
return z return z
} else { } else {
return y return y
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment