Robert Griesemer, Rob Pike, Ken Thompson
-(February 5, 2009)
+(February 6, 2009)
----
Todo's:
+[ ] there is some funny-ness regarding ';' and empty statements and label decls
[ ] document illegality of package-external tuple assignments to structs
w/ private fields: P.T{1, 2} illegal since same as P.T{a: 1, b: 2} for
a T struct { a b int }.
a for loop that is following, and can break L be used inside it?
[ ] Russ: If we use x.(T) for all conversions, we could use T() for "construction"
and type literals - would resolve the parsing ambiguity of T{} in if's
-[ ] Russ: consider re-introducing "func" for function type. Make function literals
- behave like slices, etc. Require no &'s to get a function value (solves issue
- of func{} vs &func{} vs &func_name).
Closed:
+[x] Russ: consider re-introducing "func" for function type. Make function literals
+ behave like slices, etc. Require no &'s to get a function value (solves issue
+ of func{} vs &func{} vs &func_name).
[x] onreturn/undo statement - now: defer statement
[x] comparison of non-basic types: what do we allow? what do we allow in interfaces
what about maps (require ==, copy and hash)
Operands
Constants
Qualified identifiers
- Composite Literals
- Function Literals
+ Composite literals
+ Function literals
Primary expressions
Selectors
PackageName = identifier .
-Composite Literals
+Composite literals
----
Literals for composite data structures consist of the type of the value
(avoids repeating types but complicates the spec needlessly.)
-Function Literals
+Function literals
----
A function literal represents an anonymous function. It consists of a
f := func(x, y int) int { return x + y; }
func(ch chan int) { ch <- ACK; } (reply_chan)
-Implementation restriction: A function literal can reference only
-its parameters, global variables, and variables declared within the
-function literal.
+Function literals are "closures": they may refer to variables
+defined in a surrounding function. Those variables are then shared between
+the surrounding function and the function literal, and they survive as long
+as they are accessible in any way.
Primary expressions
If T is an interface type, the expression t.M does not determine which
underlying type's M is called until the point of the call itself. Thus given
-T1 and T2, both implementing interface I with interface M, the sequence
+T1 and T2, both implementing interface I with method M, the sequence
var t1 *T1;
var t2 *T2;
only one per source file.
Initialization code may contain "go" statements, but the functions
-they invoke do not begin execution until initialization is complete.
-Therefore, all initialization code is run in a single thread of
-execution.
+they invoke do not begin execution until initialization of the entire
+program is complete. Therefore, all initialization code is run in a single
+thread of execution.
Furthermore, an "init()" function cannot be referred to from anywhere
in a program. In particular, "init()" cannot be called explicitly, nor