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

Issue 1712048: code review 1712048: implications of len spec change (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 1 month ago by rsc
Modified:
15 years, 1 month ago
Reviewers:
cw
CC:
r, rsc
Visibility:
Public.

Description

implications of len spec change

Patch Set 1 #

Patch Set 2 : code review 1712048: implications of len spec change #

Patch Set 3 : code review 1712048: implications of len spec change #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -8 lines) Patch
M src/pkg/os/dir_darwin.go View 1 2 1 chunk +1 line, -1 line 1 comment Download
M src/pkg/os/dir_freebsd.go View 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/os/dir_linux.go View 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/os/dir_nacl.go View 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/syscall/syscall_bsd.go View 1 chunk +2 lines, -2 lines 0 comments Download
M src/pkg/syscall/syscall_linux.go View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 5
rsc
Hello r (cc: golang-dev@googlegroups.com), I'd like you to review this change.
15 years, 1 month ago (2010-07-01 23:17:25 UTC) #1
r2
LGTM
15 years, 1 month ago (2010-07-01 23:21:40 UTC) #2
rsc
*** Submitted as http://code.google.com/p/go/source/detail?r=fcf2470b3995 *** implications of len spec change R=r CC=golang-dev http://codereview.appspot.com/1712048
15 years, 1 month ago (2010-07-02 00:49:30 UTC) #3
cw
http://codereview.appspot.com/1712048/diff/6001/7001 File src/pkg/os/dir_darwin.go (left): http://codereview.appspot.com/1712048/diff/6001/7001#oldcode61 src/pkg/os/dir_darwin.go:61: bytes := (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0])) i don't fully understand why this ...
15 years, 1 month ago (2010-07-02 03:00:31 UTC) #4
rsc
15 years, 1 month ago (2010-07-02 04:45:45 UTC) #5
> http://codereview.appspot.com/1712048/diff/6001/7001#oldcode61
> src/pkg/os/dir_darwin.go:61: bytes :=
> (*[len(dirent.Name)]byte)(unsafe.Pointer(&dirent.Name[0]))
> i don't fully understand why this change is necessary
>
> it seems as special case the compile can always figure this out

yes, the compiler can figure it out.
but the spec does not allow len(x.y) where x is a variable
(not a package) to be used as a constant, and *[n]byte
is a type, requiring a constant n.

the recent spec change restricted the number of len
expressions considered constants (see discussion on
golang-dev) so that there weren't surprises like not
calling f (because the len is a compile time constant) in

    func f() [5]int { panic("f") }
    var x *[len(f())]byte

russ
Sign in to reply to this message.

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