471,356 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,356 software developers and data experts.

Re: if / else statements not symmetric

Actually I think the code you have in mind is:

#1: *if (X) {A} else if (!X) {B}
#2: *the same

Anything that evaluates X more than once is not correct compilation of the code you originally gave.
Thanks for replying. I took a look at the code I had in mind, and it
was not if/elseif. However, it was a very complex piece of code,
involving evaluating a function that returns a bool [in other words if
(function_returns_bool(x,y,z)) {} else {}].

What I did was make the function return the opposite of what it was
returning, (ie. true instead of false) and the program worked
flawlessly, whereas before it was an infinite loop for the reasons I
gave in the OP.

However, I grant that perhaps this fix was due to some peculiarities
of the function, not the if/else statement, so I will retract my
original statement.

RL

Sep 8 '08 #1
1 1348
On Sep 8, 1:09*pm, raylopez99 <raylope...@yahoo.comwrote:

<snip>
However, I grant that perhaps this fix was due to some peculiarities
of the function, not the if/else statement, so I will retract my
original statement.
And the lesson is: before asserting that a language behaves oddly, try
to find a *simple* example which will demonstrate the issue. If you
manage to find a simple example, that's great and it will add weight
to your complaint. If you can't find a simple example, the problem
probably lies in your complicated code.

Jon
Sep 8 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.