mirror of
https://github.com/golang/go
synced 2024-11-22 05:54:40 -07:00
complete types
R=gri DELTA=29 (0 added, 12 deleted, 17 changed) OCL=25388 CL=25391
This commit is contained in:
parent
a49305df1d
commit
cdbf619750
@ -555,22 +555,14 @@ including arrays, structs, pointers, functions, interfaces, slices, maps, and
|
|||||||
channels.
|
channels.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
|
||||||
TODO: not sure the rest of this section this is needed; it's all covered or should be covered in the sections
|
|
||||||
that follow.
|
|
||||||
</p>
|
|
||||||
<p>
|
<p>
|
||||||
At any point in the source code, a type may be <i>complete</i> or
|
At any point in the source code, a type may be <i>complete</i> or
|
||||||
<i>incomplete</i>. Most types are always complete, although their
|
<i>incomplete</i>. An incomplete type is one whose size is not
|
||||||
components, such as the base type of a pointer type, may be incomplete.
|
yet known, such as a struct whose fields are not yet fully
|
||||||
Struct and interface types are incomplete when forward declared
|
defined or a forward declared type (§Forward declarations).
|
||||||
(§Forward declarations) and become complete once they are fully
|
Most types are always complete; for instance, a pointer
|
||||||
declared. (TODO: You had array here - why?)
|
type is always complete even if it points to an incomplete type
|
||||||
The type of a variable must be complete where the variable is declared.
|
because the size of the pointer itself is always known.
|
||||||
(TODO: would be better to say what you CAN do with an interface type,
|
|
||||||
and then drop all the references to complete types in the sections
|
|
||||||
that follow. What can you do? Use one to declare a pointer variable/field/param.
|
|
||||||
Anything else?)
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The <i>interface</i> of a type is the set of methods bound to it
|
The <i>interface</i> of a type is the set of methods bound to it
|
||||||
@ -669,11 +661,10 @@ can be computed by the function <code>len(s1)</code>.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
String literals separated only by the empty string, white
|
A sequence of string literals is concatenated into a single string.
|
||||||
space, or comments are concatenated into a single string literal.
|
|
||||||
</p>
|
</p>
|
||||||
<pre class="grammar">
|
<pre class="grammar">
|
||||||
StringLit = string_lit { string_lit } .
|
StringLit = string_lit { string_lit } .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3>Array types</h3>
|
<h3>Array types</h3>
|
||||||
@ -686,7 +677,7 @@ negative.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="grammar">
|
<pre class="grammar">
|
||||||
ArrayType = "[" ArrayLength "]" ElementType .
|
ArrayType = "[" ArrayLength "]" ElementType .
|
||||||
ArrayLength = Expression .
|
ArrayLength = Expression .
|
||||||
ElementType = CompleteType .
|
ElementType = CompleteType .
|
||||||
</pre>
|
</pre>
|
||||||
@ -783,7 +774,7 @@ but are otherwise ignored.
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
// A struct corresponding to the EventIdMessage protocol buffer.
|
// A struct corresponding to the EventIdMessage protocol buffer.
|
||||||
// The tag strings contain the protocol buffer field numbers.
|
// The tag strings define the protocol buffer field numbers.
|
||||||
struct {
|
struct {
|
||||||
time_usec uint64 "field 1";
|
time_usec uint64 "field 1";
|
||||||
server_ip uint32 "field 2";
|
server_ip uint32 "field 2";
|
||||||
@ -810,9 +801,7 @@ map[string] chan
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
To permit construction of recursive and mutually recursive types,
|
The pointer base type may be an incomplete type (§Types).
|
||||||
the pointer base type may be denoted by the type name of a
|
|
||||||
forward-declared, incomplete type (§Forward declarations).
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Function types</h3>
|
<h3>Function types</h3>
|
||||||
@ -919,7 +908,7 @@ func (p T) Unlock() { ... }
|
|||||||
they implement the Lock interface as well as the File interface.
|
they implement the Lock interface as well as the File interface.
|
||||||
<p>
|
<p>
|
||||||
An interface may contain a type name T in place of a method specification.
|
An interface may contain a type name T in place of a method specification.
|
||||||
T must denote another, complete (and not forward-declared) interface type.
|
T must denote another, complete interface type.
|
||||||
Using this notation is equivalent to enumerating the methods of T explicitly
|
Using this notation is equivalent to enumerating the methods of T explicitly
|
||||||
in the interface containing T.
|
in the interface containing T.
|
||||||
|
|
||||||
@ -1087,7 +1076,7 @@ of the map.
|
|||||||
|
|
||||||
A channel provides a mechanism for two concurrently executing functions
|
A channel provides a mechanism for two concurrently executing functions
|
||||||
to synchronize execution and exchange values of a specified type. This
|
to synchronize execution and exchange values of a specified type. This
|
||||||
type must be a complete type (§Types). <font color=red>(TODO could it be incomplete?)</font>
|
type must be a complete type (§Types).
|
||||||
|
|
||||||
<pre class="grammar">
|
<pre class="grammar">
|
||||||
ChannelType = Channel | SendChannel | RecvChannel .
|
ChannelType = Channel | SendChannel | RecvChannel .
|
||||||
@ -1249,7 +1238,6 @@ TODO in another round of editing:
|
|||||||
It may make sense to have a special section in this doc containing these rule
|
It may make sense to have a special section in this doc containing these rule
|
||||||
sets for:
|
sets for:
|
||||||
|
|
||||||
complete/incomplete types
|
|
||||||
equality of types
|
equality of types
|
||||||
identity of types
|
identity of types
|
||||||
comparisons
|
comparisons
|
||||||
@ -1593,7 +1581,7 @@ type Comparable interface {
|
|||||||
<p>
|
<p>
|
||||||
A variable declaration creates a variable, binds an identifier to it and
|
A variable declaration creates a variable, binds an identifier to it and
|
||||||
gives it a type and optionally an initial value.
|
gives it a type and optionally an initial value.
|
||||||
The variable type must be a complete type (§Types).
|
The type must be complete (§Types).
|
||||||
</p>
|
</p>
|
||||||
<pre class="grammar">
|
<pre class="grammar">
|
||||||
VarDecl = "var" ( VarSpec | "(" [ VarSpecList ] ")" ) .
|
VarDecl = "var" ( VarSpec | "(" [ VarSpecList ] ")" ) .
|
||||||
@ -3776,7 +3764,7 @@ a <code>Pointer</code> and vice versa.
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The function <code>Sizeof</code> takes an expression denoting a
|
The function <code>Sizeof</code> takes an expression denoting a
|
||||||
variable of any type and returns the size of the variable in bytes.
|
variable of any (complete) type and returns the size of the variable in bytes.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The function <code>Offsetof</code> takes a selector (§Selectors) denoting a struct
|
The function <code>Offsetof</code> takes a selector (§Selectors) denoting a struct
|
||||||
|
Loading…
Reference in New Issue
Block a user