|
Have you been to QA lately?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Without further information, it is obvious that the programmer intended ProcessCarrierAnimations() to only be called if ProcessFlyouts() returns false.
I'm with OriginalGriff on this..
ProcessCarrierAnimations() || more;
This is clearly the better way to express intent that using a bitwise OR. Unless there are tests like this all over the code done with bitwise ORs, using one here requires the next programmer to notice you did something atypical here in a fairly subtle way, which means its a maintenance hazard, which in my book is part of the definition of poor coding.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
|
Exactly.
|
|
|
|
|
Yep, but this is a workaround, not a best practice though.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Entropy isn't what it used to.
|
|
|
|
|
Yuck. One of my least favorite things when reading someone else's C/C++ code is when they mix logical and bit-wise operators in an expression. In this case, using a bit-wise operator on bool values just seems wrong.
Software Zen: delete this;
|
|
|
|
|
I agree, it's not something I'd use myself. I was only answering Marc's academic question
|
|
|
|
|
I thought that was the case - your response just seemed rather unNish-like .
Software Zen: delete this;
|
|
|
|
|
Heh
|
|
|
|
|
I'm not quite sure what was unexpected here. If you mean the ProcessCarrierAnimations() never gets called if (more == true) then it really was expected
However changing || to | will make it called regardless of more's value.
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
deflinek wrote: However changing || to | will make it called regardless of more's value.
Yup!
Marc
|
|
|
|
|
It will run either ProcessFlyouts, or ProcessCarrierAnimations, or neither, and the variable will tell you if it successfully ran either. I would imagine you either want && or |.
|
|
|
|
|
|
>> It will run either ProcessFlyouts, or ProcessCarrierAnimations, or neither,
Um... Not even close.
It will, unquestionably, run ProcessFlyouts. It may also run ProcessCarrierAnimations.
Truth,
James
|
|
|
|
|
That is pretty close to what I said, although that was admittedly technically wrong. (I understand how || works but apparently failed in the challenge of writing English!) "Not even close" would be "it returns banana or grapefruit depending on the wolf".
|
|
|
|
|
I assume you meant it to do this:
bool more = ProcessFlyouts();
more = ProcessCarrierAnimations() || more;
Would do the same in C and C++ as well.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: more = ProcessCarrierAnimations() || more;
Quite so. The bitwise | operator solves the problem too.
Marc
|
|
|
|
|
Yes - but I don't like bitwise operators with bools...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I assume that you want to run the second method if first returns true, if that the case you have to switch the order
bool more = ProcessFlyouts();
more = ProcessCarrierAnimations() || more;
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Kornfeld Eliyahu Peter wrote: you have to switch the order
Yes indeed. Or use the bitwise operator.
Marc
|
|
|
|
|
I do not like that change from C/C++...I mean the | and || changes...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
This isn't a change from C++. It works the same way for both operators. Doesn't it? Now I'm going to have to read up on it, dammit!
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
You have to! Otherwise you may end up with some mess if updating C/C++ to C# (what I'm doing just now)...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Nah! As long as it compiles...
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Yeah! It compiles. After then you can rub your head to find where the bug is!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|