Now new betas of AdicHelper has: (scope behavior not shown)
1: for(code1;code2;code3){ /* actions */ }
-> code1; while (code2) { /* actions */; code3}
2: forp (code1;code2;code3) { /* actions */}
-> code1; do { /* actions */; code3} while (code2)
3: for (unit u; UnitsIn...(Args)) { /* actions */ }
-> globals
group cjgrfgn_00000000=CreateGroup()
endglobals
call GroupEnumUnitsIn...(cjgrfgn_00000000,Args,null)
loop
set u=FirstOfGroup(cjgrfgn_00000000)
exitwhen u==null
call GroupRemoveUnit(cjgrfgn_00000000,u)
/* actions */
endloop
4: for (unit u; UnitsIn...(Args) use g) { /* actions */ }
-> call GroupEnumUnitsIn...(g,Args,null)
loop
set u=FirstOfGroup(g)
exitwhen u==null
call GroupRemoveUnit(g,u)
/* actions */
endloop
5: for(unit u; UnitsInGroup(g)) { /* actions */ }
-> Cycle with copying group (sorry, no code)
6: for(unit u; UnitsInGroup(g); GroupRemovePickedUnit()) { /* actions */ }
-> loop
set u=FirstOfGroup(g)
exitwhen u==null
call GroupRemoveUnit(g,u)
/* actions */
endloop
Problems are (IMHO):
Syntax 6 use two pseudofunctions, and one of them in a special place. In this
form group for has three pseudoarguments, and it make this form too similar
with form 1. GroupRemovePickedUnit() is not needed if UnitsInGroup(g) would
substituted by UnitsFromGroup(g). It will be shorter, clearer, not bug
friendly.
So I suggest "for(unit u; UnitsFromGroup(g)) { /* actions */ }" instead of it.
Syntax 3 use global, so vulnerable to recursive use. It may lead to subtle
bugs, which would be hard to find. Using local group is slower, but more
foolproof.
So I suggest to use "forg" for group for using global group, "for" - local
group:
forg (unit u; UnitsIn...(Args)) { /* actions */ } //creates global group to
cycle
for (unit u; UnitsIn...(Args)) { /* actions */ } //creates local group to cycle
Syntax 4 implement new keyword "use". It is bad for so low use.
If you want a specific group, which you use already, write:
call GroupEnumUnitsIn...(g,Args,null)
for (unit u; UnitsFromGroup(g)) { /* actions */ } //or syntax 6 if you think "UnitsFromGroup" is bad
If you want just a use of local group, look slightly above to more clear code.
So what I really want is elimination not really needed keywords ("use" and
"GroupRemovePickedUnit()") and second ";" in group for.
Vote, please. We need your opinions.
Original issue reported on code.google.com by sbratchi...@gmail.com on 13 Aug 2011 at 10:04
Original issue reported on code.google.com by
sbratchi...@gmail.com
on 13 Aug 2011 at 10:04