Christophe wrote:
>> It is not. But there is currently no nice way to express a set of
>> orthogonal flags.
> Well, you could use an array of flags ? Oh, wait, that is precisely
what
> "r", "w", "rw" would be.
> Another option is to use the power of typesafe variadic functions:
>
> enum Mode :char { read, write }
> File fOpen(string filename, Mode[]...);
>
> auto file = fOpen("test.txt", Mode.read, Mode.write);
I like the variadic version most. Another alternative
would be to use a extra struct for flags, that
supports OR'ing them in a better way than plain
enum do. Maybe we can get some inspiration from
http://doc.qt.nokia.com/4.7/qflags.html
I'd like to add, that if we once get a good IDE for D,
it won't be able to show me possible values of the mode
parameter, if its type is just string.
And files may be not the only part of phobos that will
need flags. In the end, there should be a solution that
works even though the API and possible values are not
known from C.