summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2008-09-26 16:41:50 -0700
committerRobert Griesemer <gri@golang.org>2008-09-26 16:41:50 -0700
commita8d642e2f5b79e958ac7ea21dbf5e4e3d1372167 (patch)
treed68321154ff1a7ea4309a45465a689e05d8a8327 /doc
parent450cd08c1a3e4a28d0e3ab64ffcf360e36192a6d (diff)
downloadgo-a8d642e2f5b79e958ac7ea21dbf5e4e3d1372167.tar.gz
- added language with respect to init() restrictions
R=r DELTA=10 (9 added, 0 deleted, 1 changed) OCL=16016 CL=16016
Diffstat (limited to 'doc')
-rw-r--r--doc/go_spec.txt11
1 files changed, 10 insertions, 1 deletions
diff --git a/doc/go_spec.txt b/doc/go_spec.txt
index 7b631ec04..46f0bb830 100644
--- a/doc/go_spec.txt
+++ b/doc/go_spec.txt
@@ -2499,8 +2499,17 @@ functions defined in its source. Since a package may contain more
than one source file, there may be more than one init() function, but
only one per source file.
+Initialization code may contain "go" statements, but the functions
+they invoke do not begin execution until initialization is complete.
+Therefore, all initialization code is run in a single thread of
+execution.
+
+Furthermore, an "init()" function cannot be referred to from anywhere
+in a program. In particular, "init()" cannot be called explicitly, nor
+can a pointer to "init" be assigned to a function variable).
+
If a package has imports, the imported packages are initialized
-before initializing the package itself. If multiple packages import
+before initializing the package itself. If multiple packages import
a package P, P will be initialized only once.
The importing of packages, by construction, guarantees that there can