Open MidimasterSoft opened 2 years ago
I believe the documentation is correct, because that is how XOR works. If a flag it set, it will unset it. If a flag is unset, it will set it.
The example describes using XOR to remove an enum from a set.
Then it should possibly inform that "xor" is not simply "unsetting" ... it can have "side effects" (for not yet set flags).
It acts as a "switch/flip" there. So maybe add an example (line in the sample) on how to remove something which "might" be set.
Then it should possibly inform that "xor" is not simply "unsetting" ... <
But that's what is written in the Tutorial: "Remove a flag using XOR"
..means for me "For removing a flag use XOR" And this is wrong. XOR swaps the state, but does not remove.
A clear "Removing" can only be done with the combination of AND and XOR. So why not writing:
Remove a flag using bitwise AND and XOr.
meetingDays :&~ EDays.Saturday
I'm only reporting... you decide. Thats ok for me.
meetingDays :&~ EDays.Saturday
you should write this as: meetingDays :& ~EDays.Saturday
as this is what you then do: you want to know what "meetingDays AND (complete enum except saturday)" have in common.
(~EDays.Saturday is "Monday|Tuesday|Wednesday|Thursday|Friday|Saturday")
... (~EDays.Saturday is "Monday|Tuesday|Wednesday|Thursday|Friday|Saturday")
typo: ~EDays.Saturday is "Monday|Tuesday|Wednesday|Thursday|Friday|Sunday"
I read the chapter about ENUMs at your homepage: https://blitzmax.org/docs/en/language/enums/ and found this:
Here you write that a XOR-operation removes a flag from the variable meetingDays. But this is only correct if the flag is already part of the variable. In cases, where the flag is not there this would cause a complete wrong result.The flag will be added:
The better operation is a combination of AND and XOR. This 100% removes a BIT from a variable: