FAQ
Reviewers: golang-dev1,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go


Description:
spec: fix description of initialization
The analysis does not depend on the values of the items.
Fixes issue 4648.

Please review this at https://codereview.appspot.com/7593050/

Affected files:
M doc/go_spec.html


Index: doc/go_spec.html
===================================================================
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
- "Subtitle": "Version of March 15, 2013",
+ "Subtitle": "Version of March 20, 2013",
"Path": "/ref/spec"
}-->

@@ -5602,16 +5602,19 @@
<p>
Within a package, package-level variables are initialized,
and constant values are determined, in
-data-dependent order: if the initializer of <code>A</code>
-depends on the value of <code>B</code>, <code>A</code>
+topological reference order: if the initializer of <code>A</code>
+depends on <code>B</code>, <code>A</code>
will be set after <code>B</code>.
-It is an error if such dependencies form a cycle.
-Dependency analysis is done lexically: <code>A</code>
+Dependency analysis does not depend on the actual values
+of the items being initialized, only on their appearance
+in the source.
+<code>A</code>
depends on <code>B</code> if the value of <code>A</code>
contains a mention of <code>B</code>, contains a value
whose initializer
mentions <code>B</code>, or mentions a function that
mentions <code>B</code>, 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.
Since the dependency analysis is done per package, it can produce


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Rob Pike at Mar 20, 2013 at 8:54 pm
    This brings the spec in line with both the intent and the existing
    implementations. The mention of values in the existing spec is a
    mistake.

    -rob

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Gri at Mar 20, 2013 at 9:10 pm
    +1 for removing the notion of value


    https://codereview.appspot.com/7593050/diff/1/doc/go_spec.html
    File doc/go_spec.html (right):

    https://codereview.appspot.com/7593050/diff/1/doc/go_spec.html#newcode5605
    doc/go_spec.html:5605: topological reference order: if the initializer
    of <code>A</code>
    Is "topological reference order" actually an understood term?

    how about:

    ... based on the order they are referenced: if the initializer....

    https://codereview.appspot.com/7593050/diff/1/doc/go_spec.html#newcode5619
    doc/go_spec.html:5619: in the order they appear in the source.
    There may be multiple files involved, so the order also depends on the
    order in which the files are presented to the compiler. This should be
    mentioned somewhere (it's also part of the issue).

    https://codereview.appspot.com/7593050/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • R at Mar 20, 2013 at 9:24 pm
    Hello golang-dev@googlegroups.com, gri@golang.org (cc:
    golang-dev@googlegroups.com),

    Please take another look.


    https://codereview.appspot.com/7593050/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Gri at Mar 20, 2013 at 9:28 pm
    LGTM


    https://codereview.appspot.com/7593050/diff/6001/doc/go_spec.html
    File doc/go_spec.html (right):

    https://codereview.appspot.com/7593050/diff/6001/doc/go_spec.html#newcode5719
    doc/go_spec.html:5719: order of reference: if the initializer of
    <code>A</code>
    I suggested "based on the order of reference" instead of "in the order
    of reference" because the order is (topologically) reversed: If A
    depends on B, B will be initialized first.

    Maybe it's fine since there is an example.

    https://codereview.appspot.com/7593050/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • R at Mar 20, 2013 at 9:51 pm
    Hello golang-dev@googlegroups.com, gri@golang.org (cc:
    golang-dev@googlegroups.com),

    Please take another look.


    https://codereview.appspot.com/7593050/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rsc at Mar 20, 2013 at 10:01 pm
    LGTM


    https://codereview.appspot.com/7593050/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Gri at Mar 20, 2013 at 10:02 pm
    LGTM

    https://codereview.appspot.com/7593050/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • R at Mar 20, 2013 at 10:05 pm
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=85b1cc5d35dd ***

    spec: fix description of initialization
    The analysis does not depend on the values of the items.
    Fixes issue 4648.

    R=golang-dev, gri, rsc
    CC=golang-dev
    https://codereview.appspot.com/7593050


    https://codereview.appspot.com/7593050/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedMar 20, '13 at 8:53p
activeMar 20, '13 at 10:05p
posts9
users3
websitegolang.org

3 users in discussion

R: 5 posts Gri: 3 posts Rsc: 1 post

People

Translate

site design / logo © 2022 Grokbase