using enums for flags
Trass3r
un at known.com
Wed Jan 25 16:17:51 PST 2012
> I think that it makes sense to use enums as flags, but I do _not_ think
> that it makes sense to use an enum as the type of the variable _holding_
> the flags.
>
> STC var = STC.A & STC.B;
We could easily introduce @flags enum or whatever to make it more clear
like in C#.
> just makes it worse. It should be something like
>
> uint var = STC.A & FOO.F;
To me it doesn't make any sense at all to allow bitwise operations on
different *named* enums.
I also don't see why you would really need implicit conversion to the base
type.
> For instance, std.socket uses flag enums, which is fine, but in some
> places it uses them as the type of function parameters, which is _not_ a
> good idea IMHO.
You really think int is any better??
No type safety at all.
More information about the Digitalmars-d
mailing list