If this is cool I can update callers in this CL too. This is minor ...
13 years, 11 months ago
(2011-04-04 17:09:42 UTC)
#2
If this is cool I can update callers in this CL too.
This is minor but I always look it up, double-checking myself. I think
constants would make for more readable code at the Seek call sites.
On Mon, Apr 4, 2011 at 10:06 AM, <bradfitz@golang.org> wrote:
> Reviewers: golang-dev_googlegroups.com,
>
> Message:
> Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com),
>
> I'd like you to review this change to
> https://go.googlecode.com/hg
>
>
> Description:
> os: add Seek whence constants
>
> Please review this at http://codereview.appspot.com/4344062/
>
> Affected files:
> M src/pkg/os/file.go
>
>
> Index: src/pkg/os/file.go
> ===================================================================
> --- a/src/pkg/os/file.go
> +++ b/src/pkg/os/file.go
> @@ -61,6 +61,13 @@
> O_CREATE int = O_CREAT // create a new file if none
> exists.
> )
>
> +// Seek whence values.
> +const (
> + SEEK_ORIGIN int = 0 // seek relative to the origin of the file
> + SEEK_RELATIVE int = 1 // seek relative to the current offset
> + SEEK_END int = 2 // seek relative to the end
> +)
> +
> type eofError int
>
> func (eofError) String() string { return "EOF" }
>
>
>
People keep asking for these. I guess 0, 1, and 2 are too hard to ...
13 years, 11 months ago
(2011-04-04 17:13:00 UTC)
#3
People keep asking for these. I guess 0, 1, and 2 are too hard to remember.
They're certainly not too hard to type.
Russ? Anyone?
By the way, we should probably create an os.Create function because the
community has made Open too hard to use.
On Mon, Apr 4, 2011 at 10:13 AM, <r@golang.org> wrote: > People keep asking for ...
13 years, 11 months ago
(2011-04-04 17:22:24 UTC)
#4
On Mon, Apr 4, 2011 at 10:13 AM, <r@golang.org> wrote:
> People keep asking for these. I guess 0, 1, and 2 are too hard to
> remember. They're certainly not too hard to type.
>
I would rather type more and have my code be readable to others who might
not have memorized some magic constants from rarely-used APIs.
But I can make my own constants in my own files if necessary.
Either way.
> Russ? Anyone?
>
> By the way, we should probably create an os.Create function because the
> community has made Open too hard to use.
You joke, but I also cringe at all those useless zeros in the common case of
opening files for reading.
Reading and writing are separate actions. Go inherited C's API (~the
kernel's API) but it doesn't have to, imho.
I was just rereading a piece of the John Lions Unix book this morning. Perhaps ...
13 years, 11 months ago
(2011-04-04 17:23:08 UTC)
#5
I was just rereading a piece of the John Lions Unix book this morning. Perhaps
my knowledge runs too deep.
Two things bother me though:
1) The way all the constants in os are defined (repeated int = ) should maybe be
cleaned up.
2) The names are horrible throughout the os constant space. Not sure we can do
much about that; it's silly to change the names from the underlying system. But
blech.
That said, seek(3) does not name any constants. They're 0, 1, and 2. Moreover,
the names in open(3) differ from ours; Go's have O_ on every one. Blech again.
How did Go get worse names? Probably my fault, and worth fixing, maybe in the
add-Create pass.
-rob
On Apr 4, 2011, at 10:22 AM, Brad Fitzpatrick wrote: > > By the way, ...
13 years, 11 months ago
(2011-04-04 17:23:57 UTC)
#6
On Apr 4, 2011, at 10:22 AM, Brad Fitzpatrick wrote:
>
> By the way, we should probably create an os.Create function because the
> community has made Open too hard to use.
>
> You joke, but I also cringe at all those useless zeros in the common case of
opening files for reading.
That was not a joke, it's truth.
-rob
On Mon, Apr 4, 2011 at 10:23 AM, Rob 'Commander' Pike <r@google.com> wrote: ... > ...
13 years, 11 months ago
(2011-04-04 17:28:35 UTC)
#7
On Mon, Apr 4, 2011 at 10:23 AM, Rob 'Commander' Pike <r@google.com> wrote:
...
>
> That said, seek(3) does not name any constants. They're 0, 1, and 2.
> Moreover, the names in open(3) differ from ours; Go's have O_ on every one.
You seem concerned with consistency with C. Why?
On Apr 4, 2011, at 10:28 AM, Brad Fitzpatrick wrote: > On Mon, Apr 4, ...
13 years, 11 months ago
(2011-04-04 17:36:09 UTC)
#8
On Apr 4, 2011, at 10:28 AM, Brad Fitzpatrick wrote:
> On Mon, Apr 4, 2011 at 10:23 AM, Rob 'Commander' Pike <r@google.com> wrote:
> ...
>
> That said, seek(3) does not name any constants. They're 0, 1, and 2.
Moreover, the names in open(3) differ from ours; Go's have O_ on every one.
>
> You seem concerned with consistency with C. Why?
That's not the issue. The issue is that the constants are not Gopherish and
they're needlessly long, longer than even their C equivalents.
-rob
I don't care about the names. I just made them up to start the conversation. ...
13 years, 11 months ago
(2011-04-04 19:22:07 UTC)
#10
I don't care about the names. I just made them up to start the
conversation.
Do you object to adding constants, though?
On Mon, Apr 4, 2011 at 12:08 PM, Russ Cox <rsc@google.com> wrote:
> No.
>
> These aren't even the right names.
>
> Russ
>
Should I update call sites in this CL? Generally convenience CLs do, but I get ...
13 years, 11 months ago
(2011-04-04 19:46:01 UTC)
#14
Should I update call sites in this CL?
Generally convenience CLs do, but I get the sense that you guys might prefer
0, 1, 2.
On Mon, Apr 4, 2011 at 12:41 PM, <rsc@golang.org> wrote:
> LGTM
>
>
>
> http://codereview.appspot.com/4344062/
>
On Apr 4, 2011, at 12:45 PM, Brad Fitzpatrick wrote: > Should I update call ...
13 years, 11 months ago
(2011-04-04 19:47:01 UTC)
#15
On Apr 4, 2011, at 12:45 PM, Brad Fitzpatrick wrote:
> Should I update call sites in this CL?
>
> Generally convenience CLs do, but I get the sense that you guys might prefer
0, 1, 2.
Might as well. I don't promise to use the new constants everywhere, but Seeks
are pretty rare.
-rob
Issue 4344062: code review 4344062: os: add Seek whence constants
(Closed)
Created 13 years, 11 months ago by bradfitz
Modified 13 years, 11 months ago
Reviewers:
Base URL:
Comments: 0