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

Issue 7307083: code review 7307083: spec: clarify when range x does not evaluate x (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 1 month ago by rsc
Modified:
12 years ago
Reviewers:
adonovan
CC:
r, golang-dev
Visibility:
Public.

Description

spec: clarify when range x does not evaluate x Fixes issue 4644.

Patch Set 1 #

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

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

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

Total comments: 6

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

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

Total comments: 2

Patch Set 7 : diff -r 70a50cc39caf https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 8 : diff -r eb5703eead92 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -5 lines) Patch
M doc/go_spec.html View 1 2 3 4 5 6 2 chunks +11 lines, -5 lines 0 comments Download

Messages

Total messages: 20
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
12 years, 1 month ago (2013-02-09 19:27:55 UTC) #1
r
https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html#newcode4376 doc/go_spec.html:4376: and that length may be constant. may be?
12 years, 1 month ago (2013-02-09 21:13:29 UTC) #2
rsc
PTAL https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html#newcode4376 doc/go_spec.html:4376: and that length may be constant. On 2013/02/09 ...
12 years, 1 month ago (2013-02-09 22:39:33 UTC) #3
r
that 'and' makes it sound like it's a consequence of the range rules rather than ...
12 years, 1 month ago (2013-02-10 03:53:20 UTC) #4
rsc
PTAL
12 years, 1 month ago (2013-02-11 13:05:45 UTC) #5
r
LGTM but get other input https://codereview.appspot.com/7307083/diff/12001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/12001/doc/go_spec.html#newcode4383 doc/go_spec.html:4383: length is evaluated; if ...
12 years, 1 month ago (2013-02-11 14:29:54 UTC) #6
adonovan
This spec change should probably be accompanied by appropriate tests in $GOROOT/test/range.go. https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html File doc/go_spec.html ...
12 years, 1 month ago (2013-02-11 19:45:23 UTC) #7
rsc
https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html#newcode4376 doc/go_spec.html:4376: and that length may be constant. Alan, does the ...
12 years, 1 month ago (2013-02-12 12:43:27 UTC) #8
adonovan
https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html#newcode4376 doc/go_spec.html:4376: and that length may be constant. On 2013/02/12 12:43:28, ...
12 years, 1 month ago (2013-02-12 15:15:54 UTC) #9
rsc
PTAL https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/7001/doc/go_spec.html#newcode4376 doc/go_spec.html:4376: and that length may be constant. I'm not ...
12 years ago (2013-02-15 18:18:23 UTC) #10
rsc
PTAL
12 years ago (2013-02-15 18:18:24 UTC) #11
rsc
On 2013/02/15 18:18:23, rsc wrote: > does not crash, because len(***p) is never evaluated. I ...
12 years ago (2013-02-15 18:19:15 UTC) #12
r
https://codereview.appspot.com/7307083/diff/14001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/14001/doc/go_spec.html#newcode4383 doc/go_spec.html:4383: length is evaluated; if that length is constant by ...
12 years ago (2013-02-15 18:37:06 UTC) #13
rsc
https://codereview.appspot.com/7307083/diff/14001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/14001/doc/go_spec.html#newcode4383 doc/go_spec.html:4383: length is evaluated; if that length is constant by ...
12 years ago (2013-02-15 18:44:09 UTC) #14
r
https://codereview.appspot.com/7307083/diff/14001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/14001/doc/go_spec.html#newcode4383 doc/go_spec.html:4383: length is evaluated; if that length is constant by ...
12 years ago (2013-02-15 18:56:32 UTC) #15
rsc
https://codereview.appspot.com/7307083/diff/14001/doc/go_spec.html File doc/go_spec.html (right): https://codereview.appspot.com/7307083/diff/14001/doc/go_spec.html#newcode4383 doc/go_spec.html:4383: length is evaluated; if that length is constant by ...
12 years ago (2013-02-15 19:16:55 UTC) #16
r
LGTM i still think it's confusing but i can't find a better explanation. maybe someone ...
12 years ago (2013-02-15 19:33:59 UTC) #17
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=76d9c67c6646 *** spec: clarify when range x does not evaluate x Fixes ...
12 years ago (2013-02-15 19:39:32 UTC) #18
adonovan
On 2013/02/15 19:39:32, rsc wrote: > *** Submitted as https://code.google.com/p/go/source/detail?r=76d9c67c6646 *** > > spec: clarify ...
12 years ago (2013-02-19 02:06:41 UTC) #19
rsc
12 years ago (2013-02-19 04:14:28 UTC) #20
On Mon, Feb 18, 2013 at 9:06 PM, <adonovan@google.com> wrote:

> I finally understand the distinction the original spec was trying to
> make, so I think the current wording is an improvement.  But the
> distinction is of such a hair-splitting nature that I doubt many users
> will (a) memorize it correctly and (b) use it profitably.
>
> I'd be inclined to simplify the spec in a future revision to something
> like: x is always evaluated (and let the compiler try to optimise around
> that).  Do you have a particular example that motivates the current
> semantics?


The motivation for the constant rules is to allow const x = len(...) for
various reasonable ... of array type.

The non-evaluation of the array during range falls out from rewriting for i
:= range ... as for i, n := 0, len(...); i < n; i++ (more or less).

I don't see any reason to change it at this point. Implementers need to
know but program authors almost never do. Except for not crashing in range
*x where x is nil, it already behaves the way you say people would expect.
And no one ever complains about their program not crashing.

Russ
Sign in to reply to this message.

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