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

Comments

Projects
None yet
3 participants
@griesemer
Copy link
Contributor

commented Jan 16, 2014

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

This comment has been minimized.

Copy link
Contributor Author

commented Jan 16, 2014

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

This comment has been minimized.

Copy link
Contributor

commented Jan 16, 2014

Comment 2:

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

This comment has been minimized.

Copy link
Contributor Author

commented Mar 11, 2014

Comment 3:

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

This comment has been minimized.

Copy link

commented May 6, 2014

Comment 4:

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

This comment has been minimized.

Copy link
Contributor Author

commented May 7, 2014

Comment 5:

Status changed to Started.

@griesemer

This comment has been minimized.

Copy link
Contributor Author

commented May 7, 2014

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

@rsc rsc removed the release-go1.3maybe label 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.
You can’t perform that action at this time.