From 864944400263d9d8d1a31b538841f8ad6edfc76b Mon Sep 17 00:00:00 2001
From: Rob Pike fmt.Fprintf
enables formatted printing to any output, not just a file, or how the
bufio
package can be completely separate from file I/O,
-or how the crypto
packages stitch together block and
-stream ciphers. All these ideas stem from a single interface
+or how the image
packages generate compressed
+image files. All these ideas stem from a single interface
(io.Writer
) representing a single method
(Write
). And that's only scratching the surface.
-Not directly because they do not have the same representation in memory.
+Not directly, because they do not have the same representation in memory.
It is necessary to copy the elements individually to the destination
slice. This example converts a slice of int
to a slice of
interface{}
:
@@ -841,10 +841,13 @@ for more information about how to proceed.
When are function parameters passed by value?
-Everything in Go is passed by value. A function always gets a copy of the
+As in all languages in the C family, everything in Go is passed by value.
+That is, a function always gets a copy of the
thing being passed, as if there were an assignment statement assigning the
-value to the parameter. For instance, copying a pointer value makes a copy of
-the pointer, not the data it points to.
+value to the parameter. For instance, passing an int
value
+to a function makes a copy of the int
, and passing a pointer
+value makes a copy of the pointer, but not the data it points to.
+(See the next section for a discussion of how this affects method receivers.)
@@ -946,6 +949,12 @@ floating-point numbers.
The default size of a floating-point constant is float64
.
+At the moment, all implementations use 32-bit ints, an essentially arbitrary decision.
+However, we expect that int
will be increased to 64 bits on 64-bit
+architectures in a future release of Go.
+
-In the current compilers, the analysis is crude: if a variable has its address -taken, that variable is allocated on the heap. We are working to improve this -analysis so that more data is kept on the stack. +In the current compilers, if a variable has its address taken, that variable +is a candidate for allocation on the heap. However, a basic escape +analysis recognizes some cases when such variables will not +live past the return from the function and can reside on the stack.
-Programs that perform concurrent computation should benefit from an increase in
+Programs that perform parallel computation should benefit from an increase in
GOMAXPROCS
. (See the runtime
package's
documentation.)
@@ -1227,16 +1237,16 @@ it now. Gccgo
's run-time support uses glibc
.
control; it is
compiled with a version of the Plan 9 C compiler that supports
segmented stacks for goroutines.
-Work is underway to provide the same stack management in
-gccgo
.
+The gccgo
compiler also implements segmented
+stacks, supported by recent modifications to its linker.
-The gc tool chain (5l
, 6l
, and 8l
) only
-generate statically linked binaries. All Go binaries therefore include the Go
+The linkers in the gc tool chain (5l
, 6l
, and 8l
)
+do static linking. All Go binaries therefore include the Go
run-time, along with the run-time type information necessary to support dynamic
type checks, reflection, and even panic-time stack traces.
a
to be a pointer but not b
; in Go
- var a, b *int; + var a, b *int
declares both to be pointers. This is clearer and more regular.
@@ -1381,11 +1391,11 @@ Also, the :=
short declaration form argues that a full variable
declaration should present the same order as :=
so
- var a uint64 = 1; + var a uint64 = 1has the same effect as
- a := uint64(1); + a := uint64(1)
Parsing is also simplified by having a distinct grammar for types that -- 2.48.1