No, I'm not crazy!!
This thread (if statements in c++ compared to java) got me thinking about boolean conditions. I know what boolean logic is, and I'm very comfortable with boolean logic. But I wonder if the higher level languages are selling themselves short?
He's my thought process.
I work on mainframes daily. I code a LOT in assembler. In assembler, as some of you must know, you work with condition codes set by individual instructions. On the mainframe, there are two bits used to hold the condition code of condition-code-setting instructions. With these 2 bits you get 4 combinations ("quad") of conditions to test for. Now, not all instructions set all possible conditions, but a lot do, and in assembler, you get to take the branch you need after you've tested for the condition code you desire.
Why is it that this concept of 4 conditions codes (aka 4 possible code paths) has been dumbed down into a true or false in higher level languages?
In assembler to compare two integers, you just compare them. Then, you branch if equal, less than, greater than, or not equal. In C, for example, you compare against EQ, LT, GT, or NE. If I want to test EQ, LT and GT, then that's two compares I have to code. In asm, it would be one compare and then two possible branches. Simpler.
Or, with the above scenario, is the compiler smart enough to see the multiple compares and generate the code that does a single assembler compare and then branch accordingly?