]> Cypherpunks repositories - gostls13.git/commitdiff
spec: specify order of init() calls go1.3beta2
authorRobert Griesemer <gri@golang.org>
Wed, 21 May 2014 00:46:08 +0000 (17:46 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 21 May 2014 00:46:08 +0000 (17:46 -0700)
The spec did not specify the order in which
init() functions are called. Specify that
they are called in source order since we have
now also specified the initialization order
of independent variables.

While technically a language change, no
existing code could have relied on this,
so this should not break anything.

Per suggestion from rsc.

LGTM=r, iant
R=rsc, iant, r, ken
CC=golang-codereviews
https://golang.org/cl/98420046

doc/go_spec.html

index 01770395fde77d8399300a663d522d3f51c6087c..4c80f39d4c823533c3b5525aea0d1a9b2ccfaf37 100644 (file)
@@ -6008,7 +6008,8 @@ in a program.
 <p>
 A package with no imports is initialized by assigning initial values
 to all its package-level variables followed by calling all <code>init</code>
-functions in unspecified order.
+functions in the order they appear in the source, possibly in multiple files,
+as presented to the compiler.
 If a package has imports, the imported packages are initialized
 before initializing the package itself. If multiple packages import
 a package, the imported package will be initialized only once.