Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: order of initialization needs more detail #4648

Closed
adonovan opened this issue Jan 11, 2013 · 3 comments
Closed

spec: order of initialization needs more detail #4648

adonovan opened this issue Jan 11, 2013 · 3 comments
Milestone

Comments

@adonovan
Copy link
Member

This section of the spec:
http://golang.org/ref/spec#Program_initialization_and_execution states that 'var'
declarations are initialized in topological order, tracing through functions and
definitions.  (The term used is "data-dependent" order which I think is
incorrect because the order is an entirely static property of the topology of the
reference graph, not dependent on values.)

It says that two items not related by this partial order are initialized "in the
order they appear in the source".  I assume (and gri and iant concur) that this is
another partial order such that two vars in the same file are ordered but two vars in
different files of the same package are unordered.  It would be good to be more explicit
about this.

iant adds: "Since there
is no explicit dependence between the variables in different files, in
principle it should not matter what order they are initialized in,
although of course it is possible to construct cases where it does
matter."
@rsc
Copy link
Contributor

rsc commented Jan 30, 2013

Comment 1:

Labels changed: added priority-later, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Feb 9, 2013

Comment 2:

Source files are listed in a particular order when invoking the compiler. So the source
ordering is total.

@robpike
Copy link
Contributor

robpike commented Mar 20, 2013

Comment 3:

This issue was closed by revision b636f19.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants