From cdbf619750850936c88e79238050c8fd8f2bdf6f Mon Sep 17 00:00:00 2001
From: Rob Pike
-TODO: not sure the rest of this section this is needed; it's all covered or should be covered in the sections -that follow. -
At any point in the source code, a type may be complete or -incomplete. Most types are always complete, although their -components, such as the base type of a pointer type, may be incomplete. -Struct and interface types are incomplete when forward declared -(§Forward declarations) and become complete once they are fully -declared. (TODO: You had array here - why?) -The type of a variable must be complete where the variable is declared. -(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?) +incomplete. An incomplete type is one whose size is not +yet known, such as a struct whose fields are not yet fully +defined or a forward declared type (§Forward declarations). +Most types are always complete; for instance, a pointer +type is always complete even if it points to an incomplete type +because the size of the pointer itself is always known.
The interface of a type is the set of methods bound to it
@@ -669,11 +661,10 @@ can be computed by the function len(s1)
.
-String literals separated only by the empty string, white -space, or comments are concatenated into a single string literal. +A sequence of string literals is concatenated into a single string.
-StringLit = string_lit { string_lit } . +StringLit = string_lit { string_lit } .
-ArrayType = "[" ArrayLength "]" ElementType . +ArrayType = "[" ArrayLength "]" ElementType . ArrayLength = Expression . ElementType = CompleteType .@@ -783,7 +774,7 @@ but are otherwise ignored.
// 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 { time_usec uint64 "field 1"; server_ip uint32 "field 2"; @@ -810,9 +801,7 @@ map[string] chan
-To permit construction of recursive and mutually recursive types, -the pointer base type may be denoted by the type name of a -forward-declared, incomplete type (§Forward declarations). +The pointer base type may be an incomplete type (§Types).
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 in the interface containing T. @@ -1087,7 +1076,7 @@ of the map. A channel provides a mechanism for two concurrently executing functions to synchronize execution and exchange values of a specified type. This -type must be a complete type (§Types). (TODO could it be incomplete?) +type must be a complete type (§Types).
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 sets for: -complete/incomplete types equality of types identity of types comparisons @@ -1593,7 +1581,7 @@ type Comparable interface {A variable declaration creates a variable, binds an identifier to it and gives it a type and optionally an initial value. -The variable type must be a complete type (§Types). +The type must be complete (§Types).
VarDecl = "var" ( VarSpec | "(" [ VarSpecList ] ")" ) . @@ -3776,7 +3764,7 @@ aPointer
and vice versa.The function
Sizeof
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.The function
Offsetof
takes a selector (§Selectors) denoting a struct -- 2.48.1