mirror of
https://github.com/golang/go
synced 2024-11-22 06:54:39 -07:00
- use "package block" nomenclature for exported identifier section
- same capitalization for "Declarations and scope" section as for other sections DELTA=23 (2 added, 1 deleted, 20 changed) OCL=34131 CL=34156
This commit is contained in:
parent
fe3838489f
commit
aeaab597db
@ -1052,7 +1052,7 @@ binary operations.</p>
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Two named types are identical if their type names originate in the same
|
Two named types are identical if their type names originate in the same
|
||||||
type declaration (§<a href="#Declarations_and_Scope">Declarations and Scope</a>). A named and an unnamed type
|
type declaration (§<a href="#Declarations_and_scope">Declarations and scope</a>). A named and an unnamed type
|
||||||
are never identical. Two unnamed types are identical if the corresponding
|
are never identical. Two unnamed types are identical if the corresponding
|
||||||
type literals have the same literal structure and corresponding components have
|
type literals have the same literal structure and corresponding components have
|
||||||
identical types. In detail:
|
identical types. In detail:
|
||||||
@ -1258,11 +1258,11 @@ In addition to explicit blocks in the source code, there are implicit blocks:
|
|||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Blocks nest and influence scoping (§<a href="#Declarations_and_Scope">Declarations and Scope</a>).
|
Blocks nest and influence scoping (§<a href="#Declarations_and_scope">Declarations and scope</a>).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<h2 id="Declarations_and_Scope">Declarations and Scope</h2>
|
<h2 id="Declarations_and_scope">Declarations and scope</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A declaration binds an identifier to a constant, type, variable, function, or package.
|
A declaration binds an identifier to a constant, type, variable, function, or package.
|
||||||
@ -1357,23 +1357,24 @@ Packages:
|
|||||||
unsafe
|
unsafe
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
<h3 id="Exported_identifiers">Exported identifiers</h3>
|
<h3 id="Exported_identifiers">Exported identifiers</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
By default, identifiers are visible only within the package in which they are declared.
|
An identifier may be <i>exported</i> to permit access to it from another package
|
||||||
Some identifiers are <i>exported</i> and can be referenced using
|
using a <a href="#Qualified_identifiers">qualified identifier</a>. An identifier
|
||||||
<i>qualified identifiers</i> in other packages (§<a href="#Qualified_identifiers">Qualified identifiers</a>).
|
is exported if both:
|
||||||
If an identifier satisfies these two conditions:
|
|
||||||
</p>
|
</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>the first character of the identifier's name is a Unicode upper case letter (Unicode class "Lu");
|
<li>the first character of the identifier's name is a Unicode upper case letter (Unicode class "Lu"); and
|
||||||
<li>the identifier is declared at the package level or is a field or method of a type
|
<li>the identifier is declared in the <a href="#Blocks">package block</a> or is a field or method of a type
|
||||||
declared at the top level;
|
declared in that block.
|
||||||
</ol>
|
</ol>
|
||||||
<p>
|
<p>
|
||||||
it will be exported.
|
All other identifiers are not exported.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<h3 id="Const_declarations">Const declarations</h3>
|
<h3 id="Const_declarations">Const declarations</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -1748,9 +1749,9 @@ PackageName = identifier .
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A qualified identifier accesses an identifier in
|
A qualified identifier accesses an identifier in a separate package.
|
||||||
a separate package. The identifier must be exported by that package, which
|
The identifier must be <a href="#Exported_identifiers">exported</a> by that
|
||||||
means that it must begin with a Unicode upper case letter (§<a href="#Exported_identifiers">Exported identifiers</a>).
|
package, which means that it must begin with a Unicode upper case letter.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -3013,7 +3014,7 @@ which may be omitted only if the previous statement:
|
|||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>ends with the closing parenthesis ")" of a list of declarations
|
<li>ends with the closing parenthesis ")" of a list of declarations
|
||||||
(§<a href="#Declarations_and_Scope">Declarations and Scope</a>); or</li>
|
(§<a href="#Declarations_and_scope">Declarations and scope</a>); or</li>
|
||||||
<li>ends with a closing brace "}" that is not part of an expression.
|
<li>ends with a closing brace "}" that is not part of an expression.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -4045,8 +4046,8 @@ An implementation may require that all source files for a package inhabit the sa
|
|||||||
<h3 id="Import_declarations">Import declarations</h3>
|
<h3 id="Import_declarations">Import declarations</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A source file gains access to exported identifiers (§<a href="#Exported">Exported</a>
|
A source file gains access to <a href="#Exported_identifiers">exported identifiers</a>
|
||||||
identifiers) from another package through an import declaration.
|
from another package through an import declaration.
|
||||||
In the general form, an import declaration provides an identifier
|
In the general form, an import declaration provides an identifier
|
||||||
that code in the source file may use to access the imported package's
|
that code in the source file may use to access the imported package's
|
||||||
contents and a file name referring to the (compiled) implementation of
|
contents and a file name referring to the (compiled) implementation of
|
||||||
|
Loading…
Reference in New Issue
Block a user