From: Russ Cox Date: Wed, 4 Mar 2009 22:44:51 +0000 (-0800) Subject: change Go logo to link to home page X-Git-Tag: weekly.2009-11-06~2114 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=461dd9126c9b8dc6a04b99a878e7cf1e4e1d00ea;p=gostls13.git change Go logo to link to home page fix grammar for forward declaration of interface, struct. move array down next to slice. fix type equal example for structs. R=r,gri DELTA=247 (122 added, 114 deleted, 11 changed) OCL=25694 CL=25704 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 175d530923..da6ff62c36 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -551,6 +551,8 @@ 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.)

The interface of a type is the set of methods bound to it @@ -661,6 +663,119 @@ StringLit = string_lit { string_lit } . "Alea " /* The die */ `iacta est` /* is cast */ "." +

Array types

+ +

+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 +negative. +

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

+The length is part of the array's type and must must be a constant +expression (§Constant expressions) that evaluates to a non-negative +integer value. The length of array a can be discovered +using the built-in function len(a), which is a +compile-time constant. The elements can be indexed by integer +indices 0 through the len(a)-1 (§Indexes). +

+ +
+[32]byte
+[2*N] struct { x, y int32 }
+[1000]*float64
+
+ +

Slice types

+ +

+A slice is a reference to a contiguous segment of an array and +contains a numbered sequence of elements from that array. A slice +type denotes the set of all slices of arrays of its element type. +A slice value may be nil. +

+ +
+SliceType = "[" "]" ElementType .
+
+ +

+Like arrays, slices are indexable and have a length. The length of a +slice s can be discovered by the built-in function +len(s); unlike with arrays it may change during +execution. The elements can be addressed by integer indices 0 +through len(s)-1 (§Indexes). The slice index of a +given element may be less than the index of the same element in the +underlying array. +

+

+A slice, once initialized, is always associated with an underlying +array that holds its elements. A slice therfore shares storage +with its array and with other slices of the same array; by contrast, +distinct arrays always represent distinct storage. +

+

+The array underlying a slice may extend past the end of the slice. +The capacity is a measure of that extent: it is the sum of +the length of the slice and the length of the array beyond the slice; +a slice of length up to that capacity can be created by `slicing' a new +one from the original slice (§Slices). +The capacity of a slice a can be discovered using the +built-in function +

+ +
+cap(s)
+
+ +

+and the relationship between len() and cap() is: +

+ +
+0 <= len(a) <= cap(a)
+
+ +

+The value of an uninitialized slice is nil. +The length and capacity of a nil slice +are 0. A new, initialized slice value for a given element type T is +made using the built-in function make, which takes a slice type +and parameters specifying the length and optionally the capacity: +

+ +
+make([]T, length)
+make([]T, length, capacity)
+
+ +

+The make() call allocates a new, hidden array to which the returned +slice value refers. That is, calling make +

+ +
+make([]T, length, capacity)
+
+ +

+produces the same slice as allocating an array and slicing it, so these two examples +result in the same slice: +

+ +
+make([]int, 50, 100)
+new([100]int)[0:50]
+
+ +

Struct types

@@ -671,7 +786,7 @@ must be unique and field types must be complete (§Types).

-StructType = "struct" [ "{" [ FieldDeclList ] "}" ] .
+StructType = "struct" "{" [ FieldDeclList ] "}" .
 FieldDeclList = FieldDecl { ";" FieldDecl } [ ";" ] .
 FieldDecl = (IdentifierList CompleteType | [ "*" ] TypeName) [ Tag ] .
 Tag = StringLit .
@@ -745,36 +860,6 @@ struct {
 }
 
-

Array types

- -

-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 -negative. -

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

-The length is part of the array's type and must must be a constant -expression (§Constant expressions) that evaluates to a non-negative -integer value. The length of array a can be discovered -using the built-in function len(a), which is a -compile-time constant. The elements can be indexed by integer -indices 0 through the len(a)-1 (§Indexes). -

- -
-[32]byte
-[2*N] struct { x, y int32 }
-[1000]*float64
-
-

Pointer types

@@ -851,7 +936,7 @@ An interface value may be nil.

-InterfaceType      = "interface" [ "{" [ MethodSpecList ] "}" ] .
+InterfaceType      = "interface" "{" [ MethodSpecList ] "}" .
 MethodSpecList     = MethodSpec { ";" MethodSpec } [ ";" ] .
 MethodSpec         = IdentifierList Signature | InterfaceTypeName .
 InterfaceTypeName  = TypeName .
@@ -941,89 +1026,6 @@ type File interface {
 }
 
-

Slice types

- -

-A slice is a reference to a contiguous segment of an array and -contains a numbered sequence of elements from that array. A slice -type denotes the set of all slices of arrays of its element type. -A slice value may be nil. -

- -
-SliceType = "[" "]" ElementType .
-
- -

-Like arrays, slices are indexable and have a length. The length of a -slice s can be discovered by the built-in function -len(s); unlike with arrays it may change during -execution. The elements can be addressed by integer indices 0 -through len(s)-1 (§Indexes). The slice index of a -given element may be less than the index of the same element in the -underlying array. -

-

-A slice, once initialized, is always associated with an underlying -array that holds its elements. A slice therfore shares storage -with its array and with other slices of the same array; by contrast, -distinct arrays always represent distinct storage. -

-

-The array underlying a slice may extend past the end of the slice. -The capacity is a measure of that extent: it is the sum of -the length of the slice and the length of the array beyond the slice; -a slice of length up to that capacity can be created by `slicing' a new -one from the original slice (§Slices). -The capacity of a slice a can be discovered using the -built-in function -

- -
-cap(s)
-
- -

-and the relationship between len() and cap() is: -

- -
-0 <= len(a) <= cap(a)
-
- -

-The value of an uninitialized slice is nil. -The length and capacity of a nil slice -are 0. A new, initialized slice value for a given element type T is -made using the built-in function make, which takes a slice type -and parameters specifying the length and optionally the capacity: -

- -
-make([]T, length)
-make([]T, length, capacity)
-
- -

-The make() call allocates a new, hidden array to which the returned -slice value refers. That is, calling make -

- -
-make([]T, length, capacity)
-
- -

-produces the same slice as allocating an array and slicing it, so these two examples -result in the same slice: -

- -
-make([]int, 50, 100)
-new([100]int)[0:50]
-
- -

Map types

@@ -1208,20 +1210,24 @@ type (

-these types are equal +these types are equal:

 T0 and T0
 T0 and T1
 T0 and []string
-T2 and T3
 T4 and T5
-T3 and struct { a int; int }
+T3 and struct { a int; c int }
 

-and these types are identical +T2 and T3 are not equal because +they have different field names. +

+ +

+These types are identical:

@@ -1548,7 +1554,7 @@ to a new type.  TODO: what exactly is a "new type"?
 
 TypeDecl     = "type" ( TypeSpec | "(" [ TypeSpecList ] ")" ) .
 TypeSpecList = TypeSpec { ";" TypeSpec } [ ";" ] .
-TypeSpec     = identifier Type .
+TypeSpec     = identifier ( Type | "struct" | "interface" ) .
 
@@ -1559,9 +1565,11 @@ type (
 	Polar Point
 )
 
+type Comparable interface
+
 type TreeNode struct {
 	left, right *TreeNode;
-	value Point;
+	value *Comparable;
 }
 
 type Comparable interface {