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

Issue 4444050: code review 4444050: go spec: clarify semantics of range clause (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 10 months ago by gri
Modified:
13 years, 10 months ago
Reviewers:
r, rsc, iant
CC:
r, rsc, iant, ken2, r2, bradfitz, rog, golang-dev
Visibility:
Public.

Description

go spec: clarify semantics of range clause This CL proposes some subtle language changes in an attempt to clarify the semantics of range clauses and simplify uses of maps. - nil maps behave like empty maps; but attempting to set a value in a nil map causes a run-time panic - nil channels are never ready for communication; sending or reading from a nil channel blocks forever - if there is only one index iteration variable in a range clause and len(range expression) would be a constant, the range expression is not evaluated. (was discrepancy with len/cap before) - the notion of what is a constant expression len(x) for (pointer to) arrays x has been generalized and simplified (can still be syntactically decided) (before: more restrictive syntactic rule that was not consistently implemented) Fixes issue 1713.

Patch Set 1 #

Total comments: 3

Patch Set 2 : diff -r 786bf832db82 https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 3 : diff -r 1c953954868a https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 1c953954868a https://go.googlecode.com/hg/ #

Total comments: 7

Patch Set 5 : diff -r 9c0e844716a6 https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 6 : diff -r 96744c61ffcf https://go.googlecode.com/hg/ #

Total comments: 3

Patch Set 7 : diff -r 96744c61ffcf https://go.googlecode.com/hg/ #

Total comments: 5

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

Patch Set 9 : diff -r ca45c67d28cf https://go.googlecode.com/hg/ #

Patch Set 10 : diff -r ca45c67d28cf https://go.googlecode.com/hg/ #

Patch Set 11 : diff -r ca45c67d28cf https://go.googlecode.com/hg/ #

Patch Set 12 : diff -r 29f6e2e230a3 https://go.googlecode.com/hg/ #

Patch Set 13 : diff -r 29f6e2e230a3 https://go.googlecode.com/hg/ #

Patch Set 14 : diff -r 9d365f06c675 https://go.googlecode.com/hg/ #

Patch Set 15 : diff -r ddb1ff38c7c5 https://go.googlecode.com/hg/ #

Patch Set 16 : diff -r ddb1ff38c7c5 https://go.googlecode.com/hg/ #

Total comments: 6

Patch Set 17 : diff -r f39664db2e15 https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 18 : diff -r 1f61a34b6082 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+78 lines, -57 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 23 chunks +78 lines, -57 lines 0 comments Download

Messages

Total messages: 29
gri
Hello r, rsc, iant, ken2, (cc: golang-dev@googlegroups.com), I'd like you to review this change to ...
13 years, 10 months ago (2011-04-19 21:04:51 UTC) #1
r
http://codereview.appspot.com/4444050/diff/1/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/1/doc/go_spec.html#newcode3990 doc/go_spec.html:3990: occurs. A <code>nil</code> slice acts like an empty slice. ...
13 years, 10 months ago (2011-04-19 21:08:24 UTC) #2
gri
PTAL. I will make the language change (len(nil channel) -> panic) if everybody agrees. - ...
13 years, 10 months ago (2011-04-19 21:19:00 UTC) #3
rsc
I think this is very very murky. I really have no idea what the semantics ...
13 years, 10 months ago (2011-04-19 21:20:53 UTC) #4
r2
i agree it's murky, but i think that's largely because it's a set of unimportant ...
13 years, 10 months ago (2011-04-19 22:14:47 UTC) #5
r2
I'm happy with len(nil channel) being a panic. I'm more interested in specifying what these ...
13 years, 10 months ago (2011-04-19 22:41:49 UTC) #6
r
http://codereview.appspot.com/4444050/diff/4001/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/4001/doc/go_spec.html#newcode3973 doc/go_spec.html:3973: is equivalent to an empty slice or map. In ...
13 years, 10 months ago (2011-04-19 22:44:03 UTC) #7
bradfitz
On Tue, Apr 19, 2011 at 3:14 PM, Rob 'Commander' Pike <r@google.com> wrote: > i ...
13 years, 10 months ago (2011-04-19 23:18:56 UTC) #8
gri
PTAL. I have made an attempt to fix the situation; and thus the newly uploaded ...
13 years, 10 months ago (2011-04-20 00:40:36 UTC) #9
r
http://codereview.appspot.com/4444050/diff/12001/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/12001/doc/go_spec.html#newcode3972 doc/go_spec.html:3972: except for arrays where it may not be evaluated ...
13 years, 10 months ago (2011-04-20 23:17:16 UTC) #10
gri
PTAL http://codereview.appspot.com/4444050/diff/12001/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/12001/doc/go_spec.html#newcode3972 doc/go_spec.html:3972: except for arrays where it may not be ...
13 years, 10 months ago (2011-04-21 00:00:17 UTC) #11
r
http://codereview.appspot.com/4444050/diff/4006/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/4006/doc/go_spec.html#newcode3974 doc/go_spec.html:3974: except if the expression is an array, in which ...
13 years, 10 months ago (2011-04-21 00:07:17 UTC) #12
gri
PTAL http://codereview.appspot.com/4444050/diff/4006/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/4006/doc/go_spec.html#newcode3974 doc/go_spec.html:3974: except if the expression is an array, in ...
13 years, 10 months ago (2011-04-21 16:57:26 UTC) #13
r
http://codereview.appspot.com/4444050/diff/16001/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/16001/doc/go_spec.html#newcode3969 doc/go_spec.html:3969: it can always be omitted without changing the meaning ...
13 years, 10 months ago (2011-04-21 17:12:00 UTC) #14
gri
and uploaded http://codereview.appspot.com/4444050/diff/16001/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/16001/doc/go_spec.html#newcode3993 doc/go_spec.html:3993: case, if only the first iteration variable ...
13 years, 10 months ago (2011-04-21 17:15:49 UTC) #15
r
LGTM
13 years, 10 months ago (2011-04-21 17:26:16 UTC) #16
rsc
Not before the next weekly release. I am not convinced that the nil map and ...
13 years, 10 months ago (2011-04-21 19:45:57 UTC) #17
gri
On Thu, Apr 21, 2011 at 12:45 PM, <rsc@golang.org> wrote: > Not before the next ...
13 years, 10 months ago (2011-04-21 20:27:40 UTC) #18
iant
http://codereview.appspot.com/4444050/diff/5002/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/5002/doc/go_spec.html#newcode3996 doc/go_spec.html:3996: is a constant). I see what you are trying ...
13 years, 10 months ago (2011-04-21 21:06:38 UTC) #19
rog
On 21 April 2011 20:45, <rsc@golang.org> wrote: > Not before the next weekly release. > ...
13 years, 10 months ago (2011-04-21 21:25:59 UTC) #20
gri
PTAL. - nil maps behave like empty maps - nil channels are never ready for ...
13 years, 10 months ago (2011-05-02 23:57:57 UTC) #21
gri
Hello r, rsc, iant, ken2, r2, bradfitz, rog (cc: golang-dev@googlegroups.com), I'd like you to review ...
13 years, 10 months ago (2011-05-09 21:52:03 UTC) #22
rsc
LGTM http://codereview.appspot.com/4444050/diff/30001/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/30001/doc/go_spec.html#newcode2432 doc/go_spec.html:2432: Similarly, if an assignment to a map has ...
13 years, 10 months ago (2011-05-10 17:57:41 UTC) #23
r2
i'll do a careful review later but it looks good on quick scan probably want ...
13 years, 10 months ago (2011-05-10 18:15:57 UTC) #24
gri
PTAL. Also added more text to the section on implementation differences. http://codereview.appspot.com/4444050/diff/30001/doc/go_spec.html File doc/go_spec.html (right): ...
13 years, 10 months ago (2011-05-10 18:54:58 UTC) #25
rsc
LGTM
13 years, 10 months ago (2011-05-10 19:19:36 UTC) #26
iant
LGTM
13 years, 10 months ago (2011-05-10 20:04:39 UTC) #27
r
LGTM http://codereview.appspot.com/4444050/diff/30002/doc/go_spec.html File doc/go_spec.html (right): http://codereview.appspot.com/4444050/diff/30002/doc/go_spec.html#newcode1178 doc/go_spec.html:1178: A <code>nil</code> map behaves like an empty map ...
13 years, 10 months ago (2011-05-12 14:57:28 UTC) #28
gri
13 years, 10 months ago (2011-05-12 16:16:03 UTC) #29
*** Submitted as http://code.google.com/p/go/source/detail?r=c85198087f01 ***

go spec: clarify semantics of range clause

This CL proposes some subtle language changes
in an attempt to clarify the semantics of range
clauses and simplify uses of maps.

- nil maps behave like empty maps; but attempting
  to set a value in a nil map causes a run-time panic
- nil channels are never ready for communication;
  sending or reading from a nil channel blocks forever
- if there is only one index iteration variable in a
  range clause and len(range expression) would be a constant,
  the range expression is not evaluated.
  (was discrepancy with len/cap before)
- the notion of what is a constant expression len(x)
  for (pointer to) arrays x has been generalized and
  simplified (can still be syntactically decided)
  (before: more restrictive syntactic rule that was not
  consistently implemented)

Fixes issue 1713.

R=r, rsc, iant, ken2, r2, bradfitz, rog
CC=golang-dev
http://codereview.appspot.com/4444050
Sign in to reply to this message.

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