You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While #27253 aligned the behavior of hasMasksSet between the python and c++ implementation its behavior seems a bit confusing.
Currently hasMasksSet[0x03] would yield true on 0b0000 0001 AND on 0b0000 0010 since it returns true if any of the bits is set. The semantics of the method would suggest it would only yield true if all bits in the mask are set.
The behavior which is currently implemented would be more suitable for a method with the name hasAtLeastOneMaskSet while hasMasksSet should only return true if all bits are set.
💁♂️ Suggestion
Add new method hasAtLeastOneMaskSet which implements the current behavior of hasMasksSet
Change implementation of hasMasksSet to only return true if all bits in the mask are set
The text was updated successfully, but these errors were encountered:
I am not against changing the name as I agree it does not state clearly what it does.
That said if you expect a well defined value one can just use value no ?
Fundamentally, it seems like we should do one of two things:
Disallow non-single-bit values in the array.
Have sane semantics for non-single-bit values (which should be what?) and have the name clearly express them.
We currently do not seem to have a good way other than using hasMasksSet to test for "at least one of these bits is set". But renaming hasMasksSet to hasAtLeastOneMaskSet would also not be correct, since hasMasksSet: [0x1, 0x2] does in fact require both bits to be set, right? It would need to be something like hasAtLeastOneBitFromEachMaskSet or something.
Maybe for now if we have no use cases for the "at least one bit is set" we should just take option 1..... and then if we have such use cases arise we add a different function to address them.
📖 Description
While #27253 aligned the behavior of
hasMasksSet
between the python and c++ implementation its behavior seems a bit confusing.Currently
hasMasksSet[0x03]
would yieldtrue
on0b0000 0001
AND on0b0000 0010
since it returnstrue
if any of the bits is set. The semantics of the method would suggest it would only yieldtrue
if all bits in the mask are set.The behavior which is currently implemented would be more suitable for a method with the name
hasAtLeastOneMaskSet
whilehasMasksSet
should only returntrue
if all bits are set.💁♂️ Suggestion
hasAtLeastOneMaskSet
which implements the current behavior ofhasMasksSet
hasMasksSet
to only returntrue
if all bits in the mask are setThe text was updated successfully, but these errors were encountered: