[Python-ideas] IntFlags
Cameron Simpson
cs at zip.com.au
Thu Mar 5 23:26:18 CET 2015
On 05Mar2015 05:04, Neil Girdhar <mistersheik at gmail.com> wrote:
>This is exactly why we should not have & and ~. It creates the possibility
>to write meaningless code. Have methods that clear fields and methods that
>set them. I proposed an interface to IntFields in another message.
I can see the argument against ~, unless you preagree a 1's complelment bit
range (or equivalent, whatever): feasible, given that you might refuse to
accept "unknown" flags. With a preagreed range, "~" is perfectly meaningful.
I do not see _any_ argument again "&". I would be very unhappy with an IntFlags
that didn't accept "&" and "|", and immediately subclass it and never use the
raw one again.
I'm not sure I am a fan of "remembering negation". Keep it simple. Forbid (or
document as undefined) ~ in the absense of a range agreement at setup time.
Cheers,
Cameron Simpson <cs at zip.com.au>
Favourite proverb: Ein mann der motorrad fahrt ist fuer immer jung.
More information about the Python-ideas
mailing list