From 4c6312954574ee4e147d0aef6c9f0a644abbaa44 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Tue, 12 Jul 2011 23:45:10 +1000 Subject: [PATCH] effective go: tweak the words about semicolons, parens in control structures, and make and new. R=golang-dev, adg CC=golang-dev https://golang.org/cl/4699043 --- doc/effective_go.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/effective_go.html b/doc/effective_go.html index 2ecef44f41d..296939e0dfd 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -116,7 +116,7 @@ Some formatting details remain. Very briefly,
Parentheses
Go needs fewer parentheses: control structures (if, - for, switch) do not require parentheses in + for, switch) do not have parentheses in their syntax. Also, the operator precedence hierarchy is shorter and clearer, so
@@ -405,7 +405,7 @@ break continue fallthrough return ++ -- ) }
 

the lexer always inserts a semicolon after the token. This could be summarized as, “if the newline comes -after a token that could end a statement, add a semicolon”. +after a token that could end a statement, insert a semicolon”.

@@ -461,7 +461,7 @@ initialization statement like that of for; and there are new control structures including a type switch and a multiway communications multiplexer, select. The syntax is also slightly different: -parentheses are not required +there are no parentheses and the bodies must always be brace-delimited.

@@ -564,7 +564,7 @@ for i := 0; i < 10; i++ {

If you're looping over an array, slice, string, or map, or reading from a channel, a range clause can -manage the loop for you. +manage the loop.

 var m map[string]int
@@ -943,8 +943,11 @@ Go has two allocation primitives, the built-in functions
 They do different things and apply to different types, which can be confusing,
 but the rules are simple.
 Let's talk about new first.
-It's a built-in function essentially the same as its namesakes
-in other languages: new(T) allocates zeroed storage for a new item of type
+It's a built-in function that allocates memory, but unlike its namesakes
+in some other languages it does not initialize the memory,
+it only zeroes it.
+That is,
+new(T) allocates zeroed storage for a new item of type
 T and returns its address, a value of type *T.
 In Go terminology, it returns a pointer to a newly allocated zero value of type
 T.