aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-11-12 14:10:16 -0800
committerRob Pike <r@golang.org>2009-11-12 14:10:16 -0800
commit9549eeecd100c2c2c8d90dd1c926149d1d22d187 (patch)
tree1ec9d82b9d3228b436d3806bbfa5a7a875a9e64b
parent454c621d91fab6b0143fd678fd2d10ed3c28a983 (diff)
downloadgo-9549eeecd100c2c2c8d90dd1c926149d1d22d187.tar.gz
go-9549eeecd100c2c2c8d90dd1c926149d1d22d187.zip
add a paragraph about semicolons to the tutorial.
fix a typo caught by kakugawa@gmail.com Fixes #92. R=rsc CC=golang-dev https://golang.org/cl/152105
-rw-r--r--doc/go_spec.html2
-rw-r--r--doc/go_tutorial.html13
-rw-r--r--doc/go_tutorial.txt11
-rw-r--r--doc/progs/echo.go2
4 files changed, 25 insertions, 3 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html
index bd98c42903..9abebfbe73 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -2300,7 +2300,7 @@ var r, ok = a[x]
<p>
the result of the index expression is a pair of values with types
-<code>(K, bool)</code>.
+<code>(V, bool)</code>.
If the key is present in the map,
the expression returns the pair <code>(a[x], true)</code>;
otherwise it returns <code>(Z, false)</code> where <code>Z</code> is
diff --git a/doc/go_tutorial.html b/doc/go_tutorial.html
index bbd87bb61c..201c503bbe 100644
--- a/doc/go_tutorial.html
+++ b/doc/go_tutorial.html
@@ -110,7 +110,7 @@ Next up, here's a version of the Unix utility <code>echo(1)</code>:
23 if i &gt; 0 {
24 s += Space
25 }
-26 s += flag.Arg(i)
+26 s += flag.Arg(i);
27 }
28 if !*omitNewline {
29 s += Newline
@@ -135,6 +135,17 @@ Semicolons aren't needed here; in fact, semicolons are unnecessary after any
top-level declaration, although they are needed as separators <i>within</i>
a parenthesized list of declarations.
<p>
+You can use semicolons just the way you would in C, C++, or Java, but if you
+prefer you can also leave them out in many cases. They <i>separate</i> statements
+rather than terminate them, so they aren't needed (but are still OK) at the end of the last
+statement in a block.
+They're also optional after braces, as in C.
+Have a look at the source to <code>echo</code>.
+The only necessary semicolons in that program are on lines 8, 15, and 21
+and of course between the elements of the <code>for</code> loop on line 22.
+The ones on line 9, 16, 26, and 31 are optional but are there because a semicolon
+on the end of a list of statements makes it easier to edit the list later.
+<p>
This program imports the <code>&quot;os&quot;</code> package to access its <code>Stdout</code> variable, of type
<code>*os.File</code>. The <code>import</code> statement is actually a declaration: in its general form,
as used in our ``hello world'' program,
diff --git a/doc/go_tutorial.txt b/doc/go_tutorial.txt
index 8d57dffb6f..b8e18dab8d 100644
--- a/doc/go_tutorial.txt
+++ b/doc/go_tutorial.txt
@@ -94,6 +94,17 @@ Semicolons aren't needed here; in fact, semicolons are unnecessary after any
top-level declaration, although they are needed as separators <i>within</i>
a parenthesized list of declarations.
+You can use semicolons just the way you would in C, C++, or Java, but if you
+prefer you can also leave them out in many cases. They <i>separate</i> statements
+rather than terminate them, so they aren't needed (but are still OK) at the end of the last
+statement in a block.
+They're also optional after braces, as in C.
+Have a look at the source to "echo".
+The only necessary semicolons in that program are on lines 8, 15, and 21
+and of course between the elements of the "for" loop on line 22.
+The ones on line 9, 16, 26, and 31 are optional but are there because a semicolon
+on the end of a list of statements makes it easier to edit the list later.
+
This program imports the "&quot;os&quot;" package to access its "Stdout" variable, of type
"*os.File". The "import" statement is actually a declaration: in its general form,
as used in our ``hello world'' program,
diff --git a/doc/progs/echo.go b/doc/progs/echo.go
index 26a2f68b50..4761c1e979 100644
--- a/doc/progs/echo.go
+++ b/doc/progs/echo.go
@@ -23,7 +23,7 @@ func main() {
if i > 0 {
s += Space
}
- s += flag.Arg(i)
+ s += flag.Arg(i);
}
if !*omitNewline {
s += Newline