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: evaluation order and initialization order specs are in contradiction #7137

Closed
griesemer opened this issue Jan 16, 2014 · 6 comments
Closed

Comments

@griesemer
Copy link
Contributor

http://tip.golang.org/ref/spec#Order_of_evaluation says that function calls (etc) are
evaluated in left-to-write order in assignments.

http://tip.golang.org/ref/spec#Program_execution says that top-level variables are
initialized in the order of their dependencies.

Here's an example where these rules contradict each other:

http://play.golang.org/p/Tg-9f8zlNy

By the section on evaluation order, f should be called before g, but by the section on
initialization order, g must be called before f, and that is what's happening.

The section on evaluation order needs to be amended.
@griesemer
Copy link
Contributor Author

Comment 1:

r suggests that we should make this case invalid - i.e., if the initialization order and
the evaluation order disagree, the program is rejected. This might also catch unexpected
errors.

@rsc
Copy link
Contributor

rsc commented Jan 16, 2014

Comment 2:

Sure, either it's invalid or it's working correctly.

@griesemer
Copy link
Contributor Author

Comment 3:

Independent to contradiction emphasized here, but related to the initialization order
specification: see the 2nd example (comment #3) of issue #7134.

@gopherbot
Copy link

Comment 4:

CL https://golang.org/cl/96000044 mentions this issue.

@griesemer
Copy link
Contributor Author

Comment 5:

Status changed to Started.

@griesemer
Copy link
Contributor Author

Comment 6:

This issue was closed by revision dbe5f88.

Status changed to Fixed.

@griesemer griesemer self-assigned this May 7, 2014
@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 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

3 participants