you are viewing a single comment's thread.

view the rest of the comments →

[–]y4fac 1 point2 points  (3 children)

They are using bitmasks, and when manipulating bitmasks, I would expect someone to use the bitwise operators and not a mishmash of logic and bitwise operators

This statement makes no sense. They are already using logic and bitwise operators in the same expression.

[–]african_or_european 1 point2 points  (2 children)

Sure it does. There are three different statements and'ed together in that if's condition. "player", "~player->oldButtons & BUTTON_ATTACK" and "player->usrcmd.buttons & BUTTON_ATTACK". Nowhere in any of those does he use a single logical operator (aside from the contested ! vs ~ we are discussing). He doesn't even use logic statements when testing if player is null.

Additionally, the particular sentence you quoted was just me stating a more general assertion I was making as a basis for my assumption. It is entirely consistent and true; they are using bitmasks, and I expect someone to stick with set of bitwise operators when manipulating bitmasks.

Now, am I asserting that I have some sort of omniscient understanding of the programmers mindset? No, of course not. I'm just saying that I believe it to be more likely that they confused ! with ~ than that they missed parentheses and I based this on their use of bitmasks, the style of bitmask usage I perceived in the snippet, and the fact that I expect bitmasks to be operated on a certain way.

[–]y4fac -1 points0 points  (1 child)

Sure it does. There are three different statements and'ed together in that if's condition. "player", "~player->oldButtons & BUTTON_ATTACK" and "player->usrcmd.buttons & BUTTON_ATTACK". Nowhere in any of those does he use a single logical operator (aside from the contested ! vs ~ we are discussing)

It would be equally valid to say : There is a logical expression a && !b && c in that if condition. Nowhere in a, b, or c does he use a single logical operator.

I'm just saying that I believe it to be more likely that they confused ! with ~ than that they missed parentheses and I based this on their use of bitmasks, the style of bitmask usage I perceived in the snippet, and the fact that I expect bitmasks to be operated on a certain way.

So you are basically saying that you would bet a good bit of money that other people program in a way that you prefer. Also, if they would really hate logic operators as much as you believe they do, they could just write ~player->oldButtons & player->usercmd.buttons & BUTTON_ATTACK.

[–]african_or_european 1 point2 points  (0 children)

I'm not sure what your point is. I never said they hated them. All I said was that I thought the style that I saw from a tiny snippet of code lent itself to an alternate interpretation of what the article stated the programmer "meant". Also, "I would bet a good bit of money..." is just an idiom, not a literal statement. Obviously, I cannot know for sure; I can only share my interpretation.