- Joined
- Aug 7, 2013
- Messages
- 1,338
Hi,
Is there a shorthand syntax for a simple for loop in VJASS? Instead of writing out loop with a counter, we could do a simple for loop syntax. I can't imagine it would be that much of a problem to simply translate this syntax into the actual loop structure JASS requires.
It would be nice if we could have 2 for loop syntax:
which would just translate to
another shorthand for loop would be nice too for just iterating over elements in an array
which again would just be translated to
It would make (at least from my point of view) the code higher level and easier to read.
Is there a shorthand syntax for a simple for loop in VJASS? Instead of writing out loop with a counter, we could do a simple for loop syntax. I can't imagine it would be that much of a problem to simply translate this syntax into the actual loop structure JASS requires.
It would be nice if we could have 2 for loop syntax:
JASS:
//the exit_condition is a boolean expression which when true will exit the for loop
//some_expression is a calculation that is performed at the end of each loop
//it should be optional
for integer i = value, exit_condition , some_expression:
statements
endfor
which would just translate to
JASS:
set local integer i = value
loop
exitwhen exit_condition //boolean expression evaluates to true
statements
...
some_expression //could simply increment i or something fancier
endloop
another shorthand for loop would be nice too for just iterating over elements in an array
JASS:
for element in myArray: //in the body we can use the name "element" or whatever to reference the ith member of the array
statements
...
endfor
which again would just be translated to
JASS:
set local integer i = 0
local SomeType current_element
loop
exitwhen i == len(myArray)
set current_element = myArray[i]
statements
...
set i = i + 1
endloop
It would make (at least from my point of view) the code higher level and easier to read.