1
0
mirror of https://github.com/golang/go synced 2024-11-22 00:24:41 -07:00

- minor corrections to go_spec.txt

- verified that all text from go_lang.txt is either present in its
  old form, or that we have corresponding updated sections for it
- delete go_lang.txt

R=r
DELTA=2389  (38 added, 2344 deleted, 7 changed)
OCL=14760
CL=14762
This commit is contained in:
Robert Griesemer 2008-09-03 15:15:51 -07:00
parent 182f91ffe0
commit 7a4ed4f8c4
2 changed files with 44 additions and 2350 deletions

File diff suppressed because it is too large Load Diff

View File

@ -191,6 +191,8 @@ type, a function, etc.
ThisIsVariable9 ThisIsVariable9
αβ αβ
Some identifiers are predeclared (see Declarations).
Numeric literals Numeric literals
---- ----
@ -1068,15 +1070,15 @@ Expressions
Operands Operands
---- ----
Operand = QualifiedIdent | Literal | "(" Expression ")" | "iota" . Operand = Literal | QualifiedIdent | "(" Expression ")" .
Literal = int_lit | float_lit | char_lit | string_lit | CompositeLit | FunctionLit . Literal = int_lit | float_lit | char_lit | string_lit | CompositeLit | FunctionLit .
Iota Iota
---- ----
Within a declaration, the reserved word "iota" represents successive Within a declaration, the predeclared operand "iota"
elements of an integer sequence. represents successive elements of an integer sequence.
It is reset to zero whenever the reserved word "const" It is reset to zero whenever the reserved word "const"
introduces a new declaration and increments as each identifier introduces a new declaration and increments as each identifier
is declared. For instance, "iota" can be used to construct is declared. For instance, "iota" can be used to construct
@ -1157,7 +1159,7 @@ complicates the spec needlessly.)
TODO(gri): These are not conversions and we could use {} instead of () in TODO(gri): These are not conversions and we could use {} instead of () in
the syntax. This will make literals such as Foo(1, 2, 3) clearly stand the syntax. This will make literals such as Foo(1, 2, 3) clearly stand
out from function calls. out from function calls. TBD.
Function Literals Function Literals
@ -1248,6 +1250,8 @@ would have no effect on ``a''.
Type guards Type guards
---- ----
TODO: write this section
Calls Calls
---- ----
@ -1354,10 +1358,14 @@ elements.
Comparison operators Comparison operators
---- ----
TODO: write this section
Logical operators Logical operators
---- ----
TODO: write this section
Address operators Address operators
---- ----
@ -1985,13 +1993,17 @@ after the declaration of the receiver type and may be forward-declared.
Predeclared functions Predeclared functions
---- ----
assert (suggested by gri)
cap cap
convert convert
len len
new new
panic panic
print print
typeof
TODO: (gri) suggests that we should consider assert() as a built-in function.
It is like panic, but takes a guard as first argument.
Conversions Conversions
@ -2201,7 +2213,7 @@ to the current package. After
the contents are accessible by sin and cos. In this instance, it is the contents are accessible by sin and cos. In this instance, it is
an error if the import introduces name conflicts. an error if the import introduces name conflicts.
Here is a complete example Go program that implements a concurrent prime sieve: Here is a complete example Go package that implements a concurrent prime sieve:
package main package main
@ -2299,7 +2311,7 @@ default for the function name main.main?
---- ----
---- ----
AS OF YET UNUSED LANGUAGE UNUSED PARTS OF OLD DOCUMENT go_lang.txt - KEEP AROUND UNTIL NOT NEEDED ANYMORE
---- ----
Guiding principles Guiding principles
@ -2577,6 +2589,31 @@ TODO: if interfaces were explicitly pointers, this gets simpler.
END] END]
Expressions
----
Expression syntax is based on that of C but with fewer precedence levels.
Expression = BinaryExpr | UnaryExpr | PrimaryExpr .
BinaryExpr = Expression binary_op Expression .
UnaryExpr = unary_op Expression .
PrimaryExpr =
identifier | Literal | "(" Expression ")" | "iota" |
Call | Conversion | Allocation | Index |
Expression "." identifier | Expression "." "(" Type ")" .
Call = Expression "(" [ ExpressionList ] ")" .
Conversion =
"convert" "(" Type [ "," ExpressionList ] ")" | ConversionType "(" [ ExpressionList ] ")" .
ConversionType = TypeName | ArrayType | MapType | StructType | InterfaceType .
Allocation = "new" "(" Type [ "," ExpressionList ] ")" .
Index = SimpleIndex | Slice .
SimpleIndex = Expression "[" Expression"]" .
Slice = Expression "[" Expression ":" Expression "]" .
TODO TODO
---- ----