Author serhiy.storchaka
Recipients barry, eli.bendersky, ethan.furman, ezio.melotti, martin.panter, r.david.murray, serhiy.storchaka
Date 2016-08-09.10:35:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1470738958.22.0.428726075235.issue23591@psf.upfronthosting.co.za>
In-reply-to
Content
The name IntFlags is inspired by the Flags attribute in C# (this is the most close concept). The "Int" prefix is added for parallel with IntEnum and because the class behaves as int in some contexts (supports operators |, &, ^, ~ and can be passed to functions that require int). I don't know whether there is a need in Flags class that is not a subclass of int.

Other languages provide something like EnumSet - a specialized set of enums. But it has different interface.

1) If there are enum members FOO and BAR, their union is {FOO, BAR}, not FOO|BAR.
2) The union member itself is not a set.
3) A set can contain only predefined set of values (IntFlag allows non-defined bits be set).

If you thing that non-int flags could be useful, you can consider adding EnumSet for general enums and IntFlags (or just Flags) for int-like enums. But I think that new API can just use a set or a tuple of enums. IntFlags is needed for compatibility with old API or C API.
History
Date User Action Args
2016-08-09 10:35:58serhiy.storchakasetrecipients: + serhiy.storchaka, barry, ezio.melotti, r.david.murray, eli.bendersky, ethan.furman, martin.panter
2016-08-09 10:35:58serhiy.storchakasetmessageid: <1470738958.22.0.428726075235.issue23591@psf.upfronthosting.co.za>
2016-08-09 10:35:58serhiy.storchakalinkissue23591 messages
2016-08-09 10:35:57serhiy.storchakacreate