On Tue, 06 Sep 2011 11:11:27 -0400, Andrei Alexandrescu <[email protected]> wrote:

On 9/6/11 10:05 AM, Jacob Carlborg wrote:
On 2011-09-06 15:02, Steven Schveighoffer wrote:
Yeah, creating a new file is implied by a combination of modes.

The one that's confusing I think is that "a" is for append, but "+" kind of tacks on appending to any other mode. It's not the most well-designed
spec for file opening. Add to that you have the "b" which is a noop on
most OSes.

There is the possibility that we could accept an alternative open mode
string, which we could design better. But we have to keep fopen's spec,
it's already used everywhere.

-Steve

Ok, I would prefer to use enums if they have sensible names. Something
like this:

File.open(Mode.read | Mode.write); // for both read and write

Honest, C's openmode strings have been around for so long, they hardly confuse anyone anymore. I'd rather use "rw" and call it a day.

That's not a valid fopen string ;)

The plus "+" is odd, especially with "a" meaning "append".

And there's that really useless "b" :)

But I think this does *not* invalidate the usage of strings to denote open mode, it just needs more design. The good thing about it is, we can augment the string flags and be binary and perfectly backwards compatible.

-Steve

Reply via email to