Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
cdbf6197
Commit
cdbf6197
authored
Feb 25, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
complete types
R=gri DELTA=29 (0 added, 12 deleted, 17 changed) OCL=25388 CL=25391
parent
a49305df
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
25 deletions
+13
-25
go_spec.html
doc/go_spec.html
+13
-25
No files found.
doc/go_spec.html
View file @
cdbf6197
...
...
@@ -555,22 +555,14 @@ including arrays, structs, pointers, functions, interfaces, slices, maps, and
channels.
</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>
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
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?)
<i>
incomplete
</i>
. 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.
</p>
<p>
The
<i>
interface
</i>
of a type is the set of methods bound to it
...
...
@@ -669,8 +661,7 @@ can be computed by the function <code>len(s1)</code>.
</p>
<p>
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.
</p>
<pre
class=
"grammar"
>
StringLit = string_lit { string_lit } .
...
...
@@ -783,7 +774,7 @@ but are otherwise ignored.
<pre>
// 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
</pre>
<p>
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).
</p>
<h3>
Function types
</h3>
...
...
@@ -919,7 +908,7 @@ func (p T) Unlock() { ... }
they implement the Lock interface as well as the File interface.
<p>
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).
<font
color=
red
>
(TODO could it be incomplete?)
</font>
type must be a complete type (§Types).
<pre
class=
"grammar"
>
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 {
<p>
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 typ
e (§Types).
The
type must be complet
e (§Types).
</p>
<pre
class=
"grammar"
>
VarDecl = "var" ( VarSpec | "(" [ VarSpecList ] ")" ) .
...
...
@@ -3776,7 +3764,7 @@ a <code>Pointer</code> and vice versa.
</p>
<p>
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>
The function
<code>
Offsetof
</code>
takes a selector (§Selectors) denoting a struct
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment