Commit 7a4ed4f8 authored by Robert Griesemer's avatar Robert Griesemer

- 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
parent 182f91ff
This diff is collapsed.
...@@ -191,6 +191,8 @@ type, a function, etc. ...@@ -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 ...@@ -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.) ...@@ -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''. ...@@ -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. ...@@ -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. ...@@ -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 ...@@ -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? ...@@ -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. ...@@ -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
---- ----
......
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