Commit aa533738 authored by Robert Griesemer's avatar Robert Griesemer

- changed compound type -> composite type

- eliminated 'structured type' terminology

SVN=118200
parent b6b8da82
The Go Programming Language The Go Programming Language
---- ----
(May 5, 2008) (May 8, 2008)
This document is an informal specification/proposal for a new systems programming This document is an informal specification/proposal for a new systems programming
language. language.
...@@ -279,7 +279,7 @@ Types ...@@ -279,7 +279,7 @@ Types
A type specifies the set of values that variables of that type may A type specifies the set of values that variables of that type may
assume, and the operators that are applicable. assume, and the operators that are applicable.
There are basic types and compound types constructed from them. There are basic types and composite types.
Basic types Basic types
...@@ -537,11 +537,8 @@ At any given time, a variable or value has exactly one dynamic ...@@ -537,11 +537,8 @@ At any given time, a variable or value has exactly one dynamic
type, which may be the same as the static type. (They will type, which may be the same as the static type. (They will
differ only if the variable has an interface type or "any" type.) differ only if the variable has an interface type or "any" type.)
Compound types may be constructed from other types by Types may be composed from other types by assembling arrays, maps,
assembling arrays, maps, channels, structures, and functions. channels, structures, and functions. They are called composite types.
Array, map and struct types are called structured types, all other types
are called unstructured. A structured type cannot contain itself.
Type = TypeName | ArrayType | ChannelType | InterfaceType | Type = TypeName | ArrayType | ChannelType | InterfaceType |
FunctionType | MapType | StructType | PointerType . FunctionType | MapType | StructType | PointerType .
...@@ -554,7 +551,7 @@ Array types ...@@ -554,7 +551,7 @@ Array types
[TODO: this section needs work regarding the precise difference between [TODO: this section needs work regarding the precise difference between
static, open and dynamic arrays] static, open and dynamic arrays]
An array is a structured type consisting of a number of elements An array is a composite type consisting of a number of elements
all of the same type, called the element type. The number of all of the same type, called the element type. The number of
elements of an array is called its length. The elements of an array elements of an array is called its length. The elements of an array
are designated by indices which are integers between 0 and the length - 1. are designated by indices which are integers between 0 and the length - 1.
...@@ -584,7 +581,7 @@ its length is a constant) using the built-in special function len(): ...@@ -584,7 +581,7 @@ its length is a constant) using the built-in special function len():
Map types Map types
---- ----
A map is a structured type consisting of a variable number of entries A map is a composite type consisting of a variable number of entries
called (key, value) pairs. For a given map, called (key, value) pairs. For a given map,
the keys and values must each be of a specific type. the keys and values must each be of a specific type.
Upon creation, a map is empty and values may be added and removed Upon creation, a map is empty and values may be added and removed
...@@ -935,10 +932,10 @@ A constant declaration gives a name to the value of a constant expression. ...@@ -935,10 +932,10 @@ A constant declaration gives a name to the value of a constant expression.
Type declarations Type declarations
---- ----
A type declaration introduces a name as a shorthand for a type. Providing only A type declaration introduces a name as a shorthand for a type. The name refers
a name without a type serves as a forward declaration: The name is declared and to an incomplete type until the type specification is complete. If no type is
given an incomplete type. Incomplete types can be used together (and only) with provided at all, the declaration effectively serves as a forward declaration.
pointer types. Incomplete types can be used together (and only) with pointer types.
TypeDecl = "type" ( TypeSpec | "(" TypeSpecList [ ";" ] ")" ). TypeDecl = "type" ( TypeSpec | "(" TypeSpecList [ ";" ] ")" ).
TypeSpec = identifier [ Type ] . TypeSpec = identifier [ Type ] .
...@@ -952,6 +949,10 @@ pointer types. ...@@ -952,6 +949,10 @@ pointer types.
Polar Point Polar Point
) )
Since incomplete types can only be used with pointer types, in a type
declaration a type may not refer to itself unless it does so with a
pointer type.
Variable declarations Variable declarations
---- ----
...@@ -1292,7 +1293,7 @@ These conversions are called ``compound conversions''. ...@@ -1292,7 +1293,7 @@ These conversions are called ``compound conversions''.
There is syntactic help to make conversion expressions simpler to write. There is syntactic help to make conversion expressions simpler to write.
If the result type is of ConversionType (a type name, array type, If the result type is of ConversionType (a type name, array type,
map type, structure type, or interface type, essentially anything map type, struct type, or interface type, essentially anything
except a pointer), the conversion can be rewritten to look except a pointer), the conversion can be rewritten to look
syntactically like a call to a function whose name is the type: syntactically like a call to a function whose name is the type:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment