diff --git a/doc/go1.2.html b/doc/go1.2.html index 2e86eb0f74..c3d5466cbc 100644 --- a/doc/go1.2.html +++ b/doc/go1.2.html @@ -7,67 +7,128 @@
+
RED TEXT IS FROM THE 1.1 DOC AND NEEDS TO BE UPDATED. (It is here for
formatting and style reference.)
-
-
-The release of Go version 1 (Go 1 or Go 1.0 for short)
-in March of 2012 introduced a new period
-of stability in the Go language and libraries.
-That stability has helped nourish a growing community of Go users
-and systems around the world.
-Several "point" releases since
-then—1.0.1, 1.0.2, and 1.0.3—have been issued.
-These point releases fixed known bugs but made
-no non-critical changes to the implementation.
-
-This new release, Go 1.1, keeps the promise
-of compatibility but adds a couple of significant
-(backwards-compatible, of course) language changes, has a long list
-of (again, compatible) library changes, and
-includes major work on the implementation of the compilers,
-libraries, and run-time.
-The focus is on performance.
-Benchmarking is an inexact science at best, but we see significant,
-sometimes dramatic speedups for many of our test programs.
-We trust that many of our users' programs will also see improvements
-just by updating their Go installation and recompiling.
-
-
-
-This document summarizes the changes between Go 1 and Go 1.2.
-Very little if any code will need modification to run with Go 1.1,
-although a couple of rare error cases surface with this release
-and need to be addressed if they arise.
-Details appear below; see the discussion of XXX.
-
+Since the release of Go version 1.1 in April, 2013,
+the release schedule has been shortened to make the release process more efficient.
+This release, Go version 1.2 or Go 1.2 for short, arrives roughly six months after 1.1,
+while 1.1 took over a year to appear after 1.0.
+Because of the shorter time scale, 1.2 is a smaller delta than the step from 1.0 to 1.1,
+but it still has some significant developments, including
+a better scheduler and one new language feature.
+Of course, Go 1.2 keeps the promise
+of compatibility.
+The overwhelming majority of programs built with Go 1.1 (or 1.0 for that matter)
+will run without any changes whatsoever when moved to 1.2,
+although the introduction of one restriction
+to a corner of the language may expose already-incorrect code
+(see the discussion of the use of nil).
-
-The Go compatibility document promises
-that programs written to the Go 1 language specification will continue to operate,
-and those promises are maintained.
-In the interest of firming up the specification, though, there are
-details about some error cases that have been clarified.
-There are also some new language features.
-
+In the interest of firming up the specification, one corner case has been clarified,
+with consequences for programs.
+There is also one new language feature.
-cmd/gc: three-index slicing to set cap as well as length (CL 10743046).
+The language now specifies that, for safety reasons,
+certain uses of nil pointers are guaranteed to trigger a run-time panic.
+For instance, in Go 1.0, given code like
+the
+Further details are in the
+design document.
+
+Updating:
+Most code that depended on the old behavior is erroneous and will fail when run.
+Such programs will need to be updated by hand.
+
+Go 1.2 adds the ability to specify the capacity as well as the length when using a slicing operation
+on an existing array or slice.
+A slicing operation creates a new slice by describing a contiguous section of an already-created array or slice:
+
+The capacity of the slice is the maximum number of elements that the slice may hold, even after reslicing;
+it reflects the size of the underlying array.
+In this example, the capacity of the
+Go 1.2 adds new syntax to allow a slicing operation to specify the capacity as well as the length.
+A second
+colon introduces the capacity value, which must be less than or equal to the capacity of the
+source slice or array, adjusted for the origin. For instance,
+
+sets the slice to have the same length as in the earlier example but its capacity is now only 4 elements (6-2).
+It is impossible to use this new slice value to access the last two elements of the original array.
+
+In this three-index notation, a missing first index (
+Further details are in the
+design document.
+
+Updating:
+This is a backwards-compatible change that affects no existing programs.
+
+A binary is still included with the distribution, but the source code for the
+
+Updating:
+Since godoc was not part of the library,
+no client code depends on the godoc sources and no updating is required.
+Changes to the language
Three-index slices
+Use of nil
+type T struct {
+ X [1<<24]byte
+ Field int32
+}
+
+func main() {
+ var x *T
+ ...
+}
+
+
+nil pointer x could be used to access memory incorrectly:
+the expression x.Field could access memory at address 1<<24.
+To prevent such unsafe behavior, in Go 1.2 the compilers now guarantee that any indirection through
+a nil pointer, such as illustrated here but also in nil pointers to arrays, nil interface values,
+nil slices, and so on, will either panic or return a correct, safe non-nil value.
+In short, any expression that explicitly or implicitly requires evaluation of a nil address is an error.
+The implementation may inject extra tests into the compiled program to enforce this behavior.
+Three-index slices
+
+
+var array [10]int
+slice := array[2:4]
+
+
+slice variable is 8.
+
+slice = array[2:4:6]
+
+
+[:i:j]) defaults to zero but the other
+two indices must always be specified explicitly.
+It is possible that future releases of Go may introduce default values for these indices.
+Changes to the implementations and tools
@@ -81,6 +142,45 @@ go/build: support including C++ code with cgo (CL 8248043).
+Godoc moved to the go.tools subrepository
+
+godoc command has moved to the
+go.tools subrepository.
+The core of the program has been split into a
+library,
+while the command itself is in a separate
+directory.
+The move allows the code to be updated easily and the separation into a library and command
+makes it easier to construct custom binaries for local sites and different deployment methods.
+
-
-To make it easier for binary distributions to access them if desired, the exp
-and old source subtrees, which are not included in binary distributions,
-have been moved to the new go.exp subrepository at
-code.google.com/p/go.exp. To access the ssa package,
-for example, run
-
-
- -There are three new packages. - -
- -go/format package provides
-a convenient way for a program to access the formatting capabilities of the
-go fmt command.
-It has two functions,
-Node to format a Go parser
-Node,
-and
-Source
-to reformat arbitrary Go source code into the standard format as provided by the
-go fmt command.
-
-@@ -404,7 +467,7 @@ described above.
encoding/json package
-now will alway escape ampersands as "\u0026" when printing strings.
+now will always escape ampersands as "\u0026" when printing strings.
It will now accept but correct invalid UTF-8 in
Marshal
(such input was previously rejected).
@@ -420,7 +483,7 @@ It also supports the generic encoding interfaces of the
encoding package
described above through the new
Marshaler,
-UnMarshaler,
+Unmarshaler,
and related
MarshalerAttr and
UnmarshalerAttr