diff --git a/doc/go_spec.html b/doc/go_spec.html index 094ec770516..c6c75ddae75 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -10,7 +10,9 @@ Open issues: Todo's: [ ] need language about function/method calls and parameter passing rules -[ ] update language with respect to forward declarations +[ ] clarify new scope rules for package-level identifiers +[ ] clarify scope of identifiers denoting imported packages (file scope) +[ ] package identifier not in any scope [ ] clarify what a field name is in struct declarations (struct{T} vs struct {T T} vs struct {t T}) [ ] need explicit language about the result type of operations @@ -450,17 +452,6 @@ including arrays, structs, pointers, functions, interfaces, slices, maps, and channels.

-

-At any point in the source code, a type may be complete or -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. -(TODO: Need to figure out how forward declarations of -interface fit in here.) -

A type may have a method set associated with it (§Interface types, §Method declarations). @@ -569,15 +560,15 @@ is a string literal.

An array is a numbered sequence of elements of a single -type, called the element type, which must be complete -(§Types). The number of elements is called the length and is never +type, called the element type. +The number of elements is called the length and is never negative.

 ArrayType   = "[" ArrayLength "]" ElementType .
 ArrayLength = Expression .
-ElementType = CompleteType .
+ElementType = Type .
 

@@ -677,13 +668,13 @@ new([100]int)[0:50] A struct is a sequence of named elements, called fields, with various types. A struct type declares an identifier and type for each field. Within a struct, field identifiers -must be unique and field types must be complete (§Types). +must be unique.

 StructType = "struct" "{" [ FieldDeclList ] "}" .
 FieldDeclList = FieldDecl { ";" FieldDecl } [ ";" ] .
-FieldDecl = (IdentifierList CompleteType | [ "*" ] TypeName) [ Tag ] .
+FieldDecl = (IdentifierList Type | [ "*" ] TypeName) [ Tag ] .
 Tag = StringLit .
 
@@ -802,10 +793,10 @@ A function value may be nil.
 FunctionType   = "func" Signature .
 Signature      = Parameters [ Result ] .
-Result         = Parameters | CompleteType .
+Result         = Parameters | Type .
 Parameters     = "(" [ ParameterList ] ")" .
 ParameterList  = ParameterDecl { "," ParameterDecl } .
-ParameterDecl  = [ IdentifierList ] ( CompleteType | "..." ) .
+ParameterDecl  = [ IdentifierList ] ( Type | "..." ) .
 

@@ -815,8 +806,6 @@ stands for one item (parameter or result) of the specified type; if absent, each type stands for one item of that type. Parameter and result lists are always parenthesized except that if there is exactly one unnamed result that is not a function type it may writen as an unparenthesized type. -The types of parameters and results must be complete. -(TODO: is completeness necessary?)

For the last parameter only, instead of a type one may write @@ -920,7 +909,7 @@ as the File interface.

An interface may contain an interface type name T in place of a method specification. -In this notation, T must denote a different, complete interface type +In this notation, T must denote a different interface type and the effect is equivalent to enumerating the methods of T explicitly in the interface.

@@ -942,17 +931,15 @@ type File interface {

A map is an unordered group of elements of one type, called the value type, indexed by a set of unique keys of another type, -called the key type. Both key and value types must be complete. -(§Types). -(TODO: is completeness necessary here?) +called the key type. A map value may be nil.

 MapType     = "map" "[" KeyType "]" ValueType .
-KeyType     = CompleteType .
-ValueType   = CompleteType .
+KeyType     = Type .
+ValueType   = Type .
 

@@ -1001,8 +988,7 @@ stored in them.

A channel provides a mechanism for two concurrently executing functions to synchronize execution and communicate by passing a value of a -specified element type. The element type must be complete (§Types). -(TODO: is completeness necessary here?) +specified element type. A value of channel type may be nil.

@@ -1358,16 +1344,14 @@ right.
 ConstDecl      = "const" ( ConstSpec | "(" [ ConstSpecList ] ")" ) .
 ConstSpecList  = ConstSpec { ";" ConstSpec } [ ";" ] .
-ConstSpec      = IdentifierList [ [ CompleteType ] "=" ExpressionList ] .
+ConstSpec      = IdentifierList [ [ Type ] "=" ExpressionList ] .
 
 IdentifierList = identifier { "," identifier } .
 ExpressionList = Expression { "," Expression } .
-
-CompleteType = Type .
 

-If the type (CompleteType) is omitted, the constants take the +If the type is omitted, the constants take the individual types of the corresponding expressions, which may be ideal integer or ideal float (§Ideal number). If the type is present, all constants take the type specified, and the types @@ -1502,12 +1486,11 @@ 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 type must be complete (§Types).

 VarDecl     = "var" ( VarSpec | "(" [ VarSpecList ] ")" ) .
 VarSpecList = VarSpec { ";" VarSpec } [ ";" ] .
-VarSpec     = IdentifierList ( CompleteType [ "=" ExpressionList ] | "=" ExpressionList ) .
+VarSpec     = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
 
@@ -1613,6 +1596,11 @@ A function declaration binds an identifier to a function (§Function types).
 FunctionDecl = "func" identifier Signature [ Block ] .
 
+

+A function declaration may omit the body. Such a declaration provides the +signature for a function implemented outside Go, such as an assembly routine. +

+
 func min(x int, y int) int {
 	if x < y {
@@ -1620,10 +1608,11 @@ func min(x int, y int) int {
 	}
 	return y;
 }
+
+func flushICache(begin, end uintptr)  // implemented externally
 

-A function must be declared or forward-declared before it can be invoked (§Forward declarations). Implementation restriction: Functions can only be declared at the package level.

@@ -1676,9 +1665,6 @@ general to parameters of functions and methods.

-Methods can be declared -only after their base type is declared or forward-declared, and invoked -only after their own declaration or forward-declaration (§Forward declarations). Implementation restriction: They can only be declared at package level.

@@ -1695,46 +1681,6 @@ argument. For instance, the method Scale has type However, a function declared this way is not a method.

-

Forward declarations

- -

-Mutually-recursive types require that one be -forward declared so that it may be named in the other. -A forward declaration of a type omits the block containing the fields -or methods of the type. -

- -
-type List struct  // forward declaration of List
-type Item struct {
-	value int;
-	next *List;
-}
-type List struct {
-	head, tail *Item
-}
-
-

-A forward-declared type is incomplete (§Types) -until it is fully declared. The full declaration must follow -before the end of the block containing the forward declaration; -it cannot be contained in an inner block. -

-

-Functions and methods may similarly be forward-declared by omitting their body. -

-
-func F(a int) int  // forward declaration of F
-func G(a, b int) int {
-	return F(a) + F(b)
-}
-func F(a int) int {
-	if a <= 0 { return 0 }
-	return G(a-1, b+1)
-}
-
- -

Expressions

@@ -4303,7 +4249,7 @@ When main.main() returns, the program exits.

Implementation restriction: The compiler assumes package main -is created by a single source file and that it is not imported by any other package. +is not imported by any other package.


@@ -4339,7 +4285,7 @@ a Pointer and vice versa.

The function Sizeof takes an expression denoting a -variable of any (complete) type and returns the size of the variable in bytes. +variable of any type and returns the size of the variable in bytes.

The function Offsetof takes a selector (§Selectors) denoting a struct