Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2681)

Issue 142880043: code review 142880043: spec: clarify variable initialization order (once more) (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 8 months ago by gri
Modified:
9 years, 7 months ago
CC:
rsc, iant, ken2, gmk, golang-codereviews
Visibility:
Public.

Description

spec: specify variable initialization order explicitly The existing spec rules on package initialization were contradictory: They specified that 1) dependent variables are initialized in dependency order, and 2) independent variables are initialized in declaration order. This 2nd rule cannot be satisfied in general. For instance, for var ( c = b + 2 a = 0 b = 1 ) because of its dependency on b, c must be initialized after b, leading to the partial order b, c. Because a is independent of b but is declared before b, we end up with the order: a, b, c. But a is also independent of c and is declared after c, so the order b, c, a should also be valid in contradiction to a, b, c. The new rules are given in form of an algorithm which outlines initialization order explicitly. gccgo and go/types already follow these rules. Fixes issue 8485.

Patch Set 1 #

Patch Set 2 : diff -r 769430bdffb74d3c36b14517b2b6972938b9428c https://code.google.com/p/go/ #

Patch Set 3 : diff -r 769430bdffb74d3c36b14517b2b6972938b9428c https://code.google.com/p/go/ #

Patch Set 4 : diff -r 769430bdffb74d3c36b14517b2b6972938b9428c https://code.google.com/p/go #

Patch Set 5 : diff -r 769430bdffb74d3c36b14517b2b6972938b9428c https://code.google.com/p/go #

Patch Set 6 : diff -r 6e76bf4838e34814288ed3596a6d0792119c4684 https://code.google.com/p/go/ #

Patch Set 7 : diff -r 6e76bf4838e34814288ed3596a6d0792119c4684 https://code.google.com/p/go/ #

Patch Set 8 : diff -r b4e2a93cc930dbf71a965b310e9eb04e57002eae https://code.google.com/p/go/ #

Patch Set 9 : diff -r b4e2a93cc930dbf71a965b310e9eb04e57002eae https://code.google.com/p/go/ #

Patch Set 10 : diff -r b4e2a93cc930dbf71a965b310e9eb04e57002eae https://code.google.com/p/go/ #

Total comments: 2

Patch Set 11 : diff -r b4e2a93cc930dbf71a965b310e9eb04e57002eae https://code.google.com/p/go/ #

Total comments: 3

Patch Set 12 : diff -r b4e2a93cc930dbf71a965b310e9eb04e57002eae https://code.google.com/p/go/ #

Patch Set 13 : diff -r b4e2a93cc930dbf71a965b310e9eb04e57002eae https://code.google.com/p/go/ #

Patch Set 14 : diff -r 7f372713681da8ede16f57aa38a794841574e340 https://code.google.com/p/go/ #

Patch Set 15 : diff -r 80d8c7b85a3472f6615c505c2169835f714fba4a https://code.google.com/p/go/ #

Patch Set 16 : diff -r 2dde8b453d26cde819352532f7b99bfb07bbd6fb https://code.google.com/p/go/ #

Patch Set 17 : diff -r 2dde8b453d26cde819352532f7b99bfb07bbd6fb https://code.google.com/p/go/ #

Total comments: 6

Patch Set 18 : diff -r 3d8bc2ff5bcfcc766f9388c47e8a1f162ae57522 https://code.google.com/p/go/ #

Total comments: 2

Patch Set 19 : diff -r 3d8bc2ff5bcfcc766f9388c47e8a1f162ae57522 https://code.google.com/p/go/ #

Patch Set 20 : diff -r 2080ff7fb64eef97158d02dbfb77ecd96f872629 https://code.google.com/p/go/ #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+38 lines, -17 lines) Patch
M doc/go_spec.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 5 chunks +38 lines, -17 lines 4 comments Download

Messages

Total messages: 31
gri
Hello r@golang.org, rsc@golang.org, iant@golang.org, ken@golang.org (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to ...
9 years, 8 months ago (2014-09-11 04:44:28 UTC) #1
gmk
Initialization order should be independent of declaration order. Please correct me if I'm wrong. Moving ...
9 years, 8 months ago (2014-09-11 11:43:09 UTC) #2
iant
On Thu, Sep 11, 2014 at 4:43 AM, <gordon.klaus@gmail.com> wrote: > > Initialization order should ...
9 years, 8 months ago (2014-09-11 15:17:55 UTC) #3
gmk
On Thu, Sep 11, 2014 at 5:17 PM, Ian Lance Taylor <iant@golang.org> wrote: > All ...
9 years, 8 months ago (2014-09-11 16:07:28 UTC) #4
gri
I agree with the sentiment but in Go we have tried to make things predictable ...
9 years, 8 months ago (2014-09-11 16:18:37 UTC) #5
rsc
I think the approach here is good, and I think the choice of wording should ...
9 years, 8 months ago (2014-09-12 04:08:51 UTC) #6
gri
This algorithm is intriguing but also the reason why gc is still incorrect in some ...
9 years, 8 months ago (2014-09-12 15:38:01 UTC) #7
rsc
On Fri, Sep 12, 2014 at 11:38 AM, Robert Griesemer <gri@golang.org> wrote: > This algorithm ...
9 years, 8 months ago (2014-09-12 16:10:26 UTC) #8
gri
Hello r@golang.org, rsc@golang.org, iant@golang.org, ken@golang.org, gordon.klaus@gmail.com, adonovan@google.com (cc: golang-codereviews@googlegroups.com), Please take another look.
9 years, 8 months ago (2014-09-12 18:07:18 UTC) #9
rsc
I'm sorry for being pedantic but I'm still not sure this is precise. If you ...
9 years, 8 months ago (2014-09-12 18:33:57 UTC) #10
gri
PTAL. I have found it difficult to describe the intuitive informal rule (first sentence in ...
9 years, 8 months ago (2014-09-12 20:34:19 UTC) #11
rsc
https://codereview.appspot.com/142880043/diff/170001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/170001/doc/go_spec.html#newcode6086 doc/go_spec.html:6086: a compiler may process multiple files belonging to the ...
9 years, 8 months ago (2014-09-12 20:54:05 UTC) #12
gri
PTAL https://codereview.appspot.com/142880043/diff/170001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/170001/doc/go_spec.html#newcode6086 doc/go_spec.html:6086: a compiler may process multiple files belonging to ...
9 years, 8 months ago (2014-09-12 20:59:10 UTC) #13
rsc
https://codereview.appspot.com/142880043/diff/190001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/190001/doc/go_spec.html#newcode6085 doc/go_spec.html:6085: Implementation restriction: To ensure reproducible initialization behavior, Yes, better. ...
9 years, 8 months ago (2014-09-12 21:18:18 UTC) #14
rsc
https://codereview.appspot.com/142880043/diff/190001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/190001/doc/go_spec.html#newcode5927 doc/go_spec.html:5927: More precisely, starting with the set <code>V</code> of all ...
9 years, 8 months ago (2014-09-12 21:28:09 UTC) #15
gri
https://codereview.appspot.com/142880043/diff/190001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/190001/doc/go_spec.html#newcode5927 doc/go_spec.html:5927: More precisely, starting with the set <code>V</code> of all ...
9 years, 8 months ago (2014-09-12 21:50:44 UTC) #16
gri
PTAL On Fri, Sep 12, 2014 at 2:50 PM, <gri@golang.org> wrote: > > https://codereview.appspot.com/142880043/diff/190001/doc/go_spec.html > ...
9 years, 8 months ago (2014-09-12 22:09:40 UTC) #17
iant
LGTM https://codereview.appspot.com/142880043/diff/310001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/310001/doc/go_spec.html#newcode5947 doc/go_spec.html:5947: by the order in which the files are ...
9 years, 7 months ago (2014-09-26 23:58:10 UTC) #18
r
LGTM but i may be missing something https://codereview.appspot.com/142880043/diff/310001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/310001/doc/go_spec.html#newcode5925 doc/go_spec.html:5925: <i>declaration order</i> ...
9 years, 7 months ago (2014-09-27 00:34:36 UTC) #19
gri
https://codereview.appspot.com/142880043/diff/310001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/310001/doc/go_spec.html#newcode5925 doc/go_spec.html:5925: <i>declaration order</i> but no sooner than any of the ...
9 years, 7 months ago (2014-09-29 18:04:24 UTC) #20
rsc
LGTM This looks fine to me. I do not intend to address this for Go ...
9 years, 7 months ago (2014-09-29 18:21:21 UTC) #21
gri
https://codereview.appspot.com/142880043/diff/320001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/320001/doc/go_spec.html#newcode6065 doc/go_spec.html:6065: sorted alphabetically, to a compiler. On 2014/09/29 18:21:20, rsc ...
9 years, 7 months ago (2014-09-29 19:42:34 UTC) #22
gri
*** Submitted as https://code.google.com/p/go/source/detail?r=191f9dc7d039 *** spec: specify variable initialization order explicitly The existing spec rules ...
9 years, 7 months ago (2014-09-29 19:44:53 UTC) #23
gobot
This CL appears to have broken the netbsd-amd64-bsiegert builder. See http://build.golang.org/log/60ca55b8d7fbca41b22237e4cfb35af211d1ff01
9 years, 7 months ago (2014-09-29 20:30:51 UTC) #24
Ralph Corderoy
https://codereview.appspot.com/142880043/diff/360001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/360001/doc/go_spec.html#newcode6064 doc/go_spec.html:6064: to present multiple files belonging to the same package ...
9 years, 7 months ago (2014-09-30 08:17:01 UTC) #25
r
https://codereview.appspot.com/142880043/diff/360001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/360001/doc/go_spec.html#newcode6064 doc/go_spec.html:6064: to present multiple files belonging to the same package ...
9 years, 7 months ago (2014-09-30 14:23:52 UTC) #26
adonovan
https://codereview.appspot.com/142880043/diff/360001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/360001/doc/go_spec.html#newcode6064 doc/go_spec.html:6064: to present multiple files belonging to the same package ...
9 years, 7 months ago (2014-09-30 14:35:05 UTC) #27
rsc
On Tue, Sep 30, 2014 at 10:35 AM, <adonovan@google.com> wrote: > Can a build system's ...
9 years, 7 months ago (2014-09-30 15:34:33 UTC) #28
adonovan
https://codereview.appspot.com/142880043/diff/360001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/142880043/diff/360001/doc/go_spec.html#newcode6064 doc/go_spec.html:6064: to present multiple files belonging to the same package ...
9 years, 7 months ago (2014-09-30 16:12:02 UTC) #29
Ralph Corderoy
If it's an encouragement then it's presumably to authors of build-tools that aren't the already ...
9 years, 7 months ago (2014-10-01 11:43:34 UTC) #30
rsc
9 years, 7 months ago (2014-10-01 13:51:42 UTC) #31
On Wed, Oct 1, 2014 at 7:43 AM, <ralph.corderoy@gmail.com> wrote:

> I don't read "lexical file-name order" as precisely "Unicode code-point
> order"; the former lets the reader use byte order, the latter makes him
> think about the bytes' encoding.  Why not give them the whole "do it
> like this" clue to avoid variation amongst those that want to comply?
> It remains an encouragement.
>

For one thing, byte order and Unicode code-point order are the same, so it
doesn't really matter.

Russ
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b