HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Does jasshelper need until loop?

01-06-2012, 04:19 PM#1
cohadar
Currently you have:
Collapse JASS:
while stayCondition
    doSomething() 
endwhile

This compiles into:
Collapse JASS:
loop
    exitwhen not stayCondition
    doSomething()
endloop

====================
Some people think this is not cool because of extra not
So a proposition is this:
Collapse JASS:
until exitCondition
    doSomething()
enduntil

This would compile into:
Collapse JASS:
loop
    exitwhen exitCondition
    doSomething()
endloop
weee, no evil extra not
01-06-2012, 04:29 PM#2
Anitarf
Don't zinc whiles already remove the extra "not" in situations where it can be removed?
01-06-2012, 04:58 PM#3
cohadar
Ofc you are right, there is just one small problem.

Zinc is implemented 100% with a parser.
Jasshelper is 50% parser and 50% vexorians hacks.

Negating expressions is not that easy as it seems.

So it comes down to this:
It takes me 15 min to add until/enduntil loops
It takes me 3 days to optimize not.

And I would rather do neither because optimization that removes 1 pjass instruction is never going to make any difference for anyone.
01-06-2012, 05:31 PM#4
Troll-Brain
until seems fine.
01-06-2012, 06:23 PM#5
cohadar
No, it does not, it is ugly and confusing.

I don't even know why I bothered posting this pool.

How about this: I promise to "optimize" the while not as soon as I get 3 days of my life I can throw away on useless stuff.
While not that happens use the f****** exitwhen if you care so much.
01-06-2012, 06:37 PM#6
Troll-Brain
Quote:
Originally Posted by cohadar
No, it does not, it is ugly and confusing.

I don't even know why I bothered posting this pool.

How about this: I promise to "optimize" the while not as soon as I get 3 days of my life I can throw away on useless stuff.
While not that happens use the f****** exitwhen if you care so much.

It seems fine.
01-06-2012, 10:09 PM#7
PurgeandFire111
In my opinion, an extra keyword isn't necessary. It is clear what the "while" does, and trying to optimize/add to jasshelper just to remove the "not" would be superfluous.
01-07-2012, 10:13 AM#8
Troll-Brain
Since i don't like to be considered as a speedfreak i will try to detail my point of view.
I suppose Cohadar opened this pool because of this.
I was wondering if "until" loop would be a good idea or not, i just wasn't sure, and in these cases i tend to refer to experience coders, and since Cohadar is supposed to be one (no sarcasm here) and opened this thread, i said myself "why not ?"

Now, i realize that's a terrible idea, there are reasons why a such loop doesn't exist in "real" languages.
But i will not use while not, instead of classic jass loop, just because removing only keyword "exitwhen" to remplace it by "not" doesn't worth it.
With a proper indentation classic jass loop can already looks like "while", i mean that doesn't really improve the readability, and add a side effect, this uneeded "not".
I repeat myself i'm not a speedfreak (even if i was when i was a beginner : All BJ are the devil, blablabla ...), else i would use silly stuff such as struct extends array with custom allocators, module abuse, ...
But in the current state i just don't see the usefulness of this loop when i'm supposed to use a while not loop.
Ofc you don't have and won't bother with me, i hope it's clear now.