On Wednesday, September 07, 2011 13:32:46 Timon Gehr wrote:
> On 09/07/2011 01:27 PM, Timon Gehr wrote:
> > On 09/07/2011 09:30 AM, Jacob Carlborg wrote:
> >> On 2011-09-06 19:39, Steven Schveighoffer wrote:
> >>> I like enums in terms of writing code that processes them, but in
> >>> terms
> >>> of calling functions with them, I mean look at a sample fstream
> >>> constructor in C++:
> >>>
> >>> fstream ifs("filename.txt", ios_base::in | ios_base::out);
> >>>
> >>> vs.
> >>>
> >>> File("filename.txt", "r+"); // or "rw"
> >>>
> >>> There's just no way you can think "rw" is less descriptive or
> >>> understandable than ios_base::in | ios_base::out.
> >>>
> >>> -Steve
> >>
> >> BTW, I think that using:
> >>
> >> Mode.read | Mode.write
> >>
> >> Instead of "rw" is the same thing as one should name variables with a
> >> proper descriptive names instead of just "a" or "b".
> >
> > I disagree: "rw" is quite obvious because you have context. It is not
> >
> > Mode.read | Mode.write vs "rw"
> >
> > but
> >
> > File("filename.txt", Mode.read | Mode.write);
> >
> > vs
> >
> > File("filename.txt", "rw");
>
> Oh, btw:
>
> final switch(Mode.read|Mode.write){
> case Mode.read: writeln(1); break;
> case Mode.write: writeln(2); break;
> }
>
> => 2
>
> hm...
Personally, I don't think that &ing or |ing enums should result in an enum,
and this case illustrates one reason why. But ultimately, the main issue IMHO
is that &ing or |ring enums doesn't generally result in a valid enum value, so
it just doesn't make sense.
- Jonathan M Davis