spec: clarify default "true" condition/tag in for/switch statements
An absent condition/tag in for and switch statements is equivalent to the predeclared constant true; not simply the expression true (which might lead to a locally defined true). Not a language change. Fixes #7404. LGTM=iant, r R=r, iant, rsc, ken CC=golang-codereviews https://golang.org/cl/68150046
This commit is contained in:
parent
5b35dc0f6f
commit
ab26623182
@ -1,6 +1,6 @@
|
|||||||
<!--{
|
<!--{
|
||||||
"Title": "The Go Programming Language Specification",
|
"Title": "The Go Programming Language Specification",
|
||||||
"Subtitle": "Version of Jan 14, 2014",
|
"Subtitle": "Version of Feb 25, 2014",
|
||||||
"Path": "/ref/spec"
|
"Path": "/ref/spec"
|
||||||
}-->
|
}-->
|
||||||
|
|
||||||
@ -4459,8 +4459,8 @@ If no case matches and there is a "default" case,
|
|||||||
its statements are executed.
|
its statements are executed.
|
||||||
There can be at most one default case and it may appear anywhere in the
|
There can be at most one default case and it may appear anywhere in the
|
||||||
"switch" statement.
|
"switch" statement.
|
||||||
A missing switch expression is equivalent to
|
A missing switch expression is equivalent to the boolean value
|
||||||
the expression <code>true</code>.
|
<code>true</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
@ -4625,7 +4625,8 @@ Condition = Expression .
|
|||||||
In its simplest form, a "for" statement specifies the repeated execution of
|
In its simplest form, a "for" statement specifies the repeated execution of
|
||||||
a block as long as a boolean condition evaluates to true.
|
a block as long as a boolean condition evaluates to true.
|
||||||
The condition is evaluated before each iteration.
|
The condition is evaluated before each iteration.
|
||||||
If the condition is absent, it is equivalent to <code>true</code>.
|
If the condition is absent, it is equivalent to the boolean value
|
||||||
|
<code>true</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -4662,7 +4663,8 @@ only if the block was executed).
|
|||||||
Any element of the ForClause may be empty but the
|
Any element of the ForClause may be empty but the
|
||||||
<a href="#Semicolons">semicolons</a> are
|
<a href="#Semicolons">semicolons</a> are
|
||||||
required unless there is only a condition.
|
required unless there is only a condition.
|
||||||
If the condition is absent, it is equivalent to <code>true</code>.
|
If the condition is absent, it is equivalent to the boolean value
|
||||||
|
<code>true</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user