diff --git a/doc/go_spec.html b/doc/go_spec.html index 4c0718f4a9..ebef65916e 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -3542,7 +3542,7 @@ using an addressable value will automatically take the address of that value: @@ -5715,19 +5715,23 @@ in unspecified order.

Within a package, package-level variables are initialized, -and constant values are determined, in -data-dependent order: if the initializer of A -depends on the value of B, A +and constant values are determined, according to +order of reference: if the initializer of A +depends on B, A will be set after B. -It is an error if such dependencies form a cycle. -Dependency analysis is done lexically: A +Dependency analysis does not depend on the actual values +of the items being initialized, only on their appearance +in the source. +A depends on B if the value of A contains a mention of B, contains a value whose initializer mentions B, or mentions a function that mentions B, recursively. +It is an error if such dependencies form a cycle. If two items are not interdependent, they will be initialized -in the order they appear in the source. +in the order they appear in the source, possibly in multiple files, +as presented to the compiler. Since the dependency analysis is done per package, it can produce unspecified results if A's initializer calls a function defined in another package that refers to B.