Adding switch(){} statement to jasshelper (good/bad idea)?

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.
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.
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.

>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...
 

Nestharus

o-o
Reaction score
84
Edit
Just realized we were arguing two completely different points from me misreading your post

Last post states this ><
End Edit
 

Nestharus

o-o
Reaction score
84
In JASS, it really wouldn't matter whether you were using a switch statement or a set of ifs. In compiled programming, the switch statement immediately goes to the set case. In compiled programming, switch statements are faster than ifs -.-, but this isn't compiled programming is it? It's interpretive, so it really doesn't matter which way or the other .



Unless jesus4lyf is arguing about how switch statements are sometimes slower than ifs o-o, and in that case I totally misunderstood because of this-

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".

And now I'm reading that ;o.

Jesus4Lyf was responding to the speed of switch statements in relation to if statements while I was responding that switch statements are different from if.

My bad : D.

I was primarily talking about the fact that they are totally different, which a lot of people didn't understand ; ). Jesus4Lyf took one small portion of my post and talked about that without saying what he was talking about ><.

In compiled programming, the switch statement immediately goes to the set case.
Are you sure? I've learned most of what you say is assumptions so I doubt I believe that. I don't see what mechanism could make that possible.

I believed he was trying to say that switch were just like if statements with that remark ><, like saying jump etc didn't exist.

I was not debating about optimized switch statements ><.

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

lol


Next time jesus4lyf needs to be more clear about what he is responding to.


Final
Also my initial post wasn't fail... my statements were completely correct -.-. Again, we were arguing too completely different points, so I could say the exact same thing about your responses -.- j4l.
 

Vexorian

Why no custom sig?
Reaction score
187
I was going to add switch to Zinc but not the ugly C-style break based ones. As for Jass, I think a chain of elseif is more readable considering JASS' audience. And any Jass switch statement would just compile to chained elseifs anyway, so...
 

Nestharus

o-o
Reaction score
84
He knows that already, he was talking about switch statement speed vrs if statement speed.

Don't worry, his statements threw me off too ; )
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
He knows that already, he was talking about switch statement speed vrs if statement speed.

Don't worry, his statements threw me off too ; )

Nestharus, you throw yourself off. Takes people 12 posts to explain a simple sentence to you at times.

I don't like the idea of switch, but its uses are fine I suppose.
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
I was going to add switch to Zinc but not the ugly C-style break based ones. As for Jass, I think a chain of elseif is more readable considering JASS' audience. And any Jass switch statement would just compile to chained elseifs anyway, so...

Yay! <3
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top