Jesus4Lyf
Good Idea™
- Reaction score
- 397
Switch statement is just multi branch goto...
jesus4lyf, given who you are I didn't expect I'd have to explain that to you ...
Again, switch statements in JASS are impossible... if you are doing it just for syntax that's just totally misleading, not to mention pointless.
Now, you may call my statements wrong when it comes to JASS, but when it comes to the real world, you'll find I'm right. JASS doesn't follow real world trends, so I may use real world examples since I assume JASS does the same thing.
And where on earth do I get those assumptions? Now we are talking about a feature from real world programming languages, not from JASS, so this is not at all an assumption. If I ever have an assumption, it only ever has to do with JASS relating to hard cold facts from real world languages. I don't just pull them out of a hat.
Important note to self: My hunches are more reliable than Nestharus' "expertise" and it appears he doesn't have any idea what he talks about.Wikipedia said:Optimized switch
It is probably true to say however that many programmers do not realize how extremely important it is to obtain a very compact range of possible values for optimization to actually occur within the switch statement. They assume, incorrectly, that simply using a switch statement in their program is inherently efficient. It may indeed be true that the code is much neater and easier to maintain - but it is certainly not necessarily always optimized for faster execution unless the values are strictly suitable. Sometimes they have to be converted first by the programmer to a more suitable range using a simple transformation (complex/lengthy transformations may defeat the purpose so should be avoided). See algorithmic efficiency for an explanation of how the programmer can "assist" the compiler to make an efficient choice. See also the section 'Compiler generated branch tables' in branch table article for why optimization is not always performed as expected and how to solve this.
>Switch statement is just multi branch goto...
Do you know how machine code works? Even I understand that there is "jump if", "jump if not", "jump" or "return" - not "jump to this, that, or the other thing based on what value it is".
>I may use real world examples since I assume JASS does the same thing.
>And where on earth do I get those assumptions?
Apparently, they're based on other guesses...