| 02-19-2009, 03:07 PM | #1 |
Another silly idea: JASS:struct aaaa string msg method onTime takes nothing returns nothing call BJDebugMsg(this.msg) endmethod method test1 takes nothing returns nothing set this.msg="=????" call TimerStart(NewTimer(), 1.00, true, method this.onTime) endmethod static method test2 takes nothing returns nothing local timer t=NewTimer() local aaaa A = aaaa.create() set A.msg="/ / / / /" call TimerStart(t, 6.00, false, method A.onTime) endmethod endstruct Becomes into: JASS:function __SetTimerData takes timer t, integer x returns timer call SetTimerData(t,x) return t endfunction struct aaaa string msg method onTime takes nothing returns nothing call BJDebugMsg(this.msg) endmethod static method __onTime takes nothing returns nothing local aaaa this = GetTimerData(GetExpiredTimer()) call BJDebugMsg(this.msg) endmethod method test1 takes nothing returns nothing set this.msg="=????" call TimerStart(__SetTimerData(NewTimer(),this), 1.00, true, function aaaa.__onTime) endmethod static method test2 takes nothing returns nothing local timer t=NewTimer() local aaaa A = aaaa.create() set A.msg="/ / / / /" call SetTimerData(t, A) call TimerStart(t, 6.00, false, function aaaa.__onTime) endmethod endstruct |
| 02-19-2009, 06:18 PM | #2 |
Sounds too specific, and requires a specific library. It's really not that hard to do local aaaa this=aaaa(GetTimerData(GetExpiredTimer())) at the start of a static method. |
| 02-19-2009, 07:37 PM | #3 |
Actually, Vex, wow. I really like this. Good stuff mang. +rep even though it means nothing to you haha. This makes it a little bit easier to unify method names so that it looks a little better. |
| 02-19-2009, 07:40 PM | #4 |
ani is right there ... only when you would have a more comprehensive idea to enable users to use nonstatic methods for all callbacks (additionally ForGroup and ForForce callbacks), it would be worth to implement such a feature ...but since there is no way to do this (as far i know) that will not happen. |
| 02-19-2009, 07:56 PM | #5 |
I would use a similar syntax to f.evaluate() and f.execute(). JASS:struct aaaa string msg method onTime takes nothing returns nothing call BJDebugMsg(I2S(GetTimerData(GetExpiredTimer())) + " -- " + this.msg) endmethod method test1 takes nothing returns nothing set this.msg="=????" call this.onTime.timed(1.00, false) endmethod static method test2 takes nothing returns nothing local aaaa A = aaaa.create() set A.msg="/ / / / /" call a.onTime.timed(6.0, false) endmethod endstruct The Problem with the syntax you suggested is, that its very specific as Antiarf said and doesnt work where you expect it to work (Condition(method A.filter) or ForGroup(g, method A.enum)). But the idea is very nice as we do not have to write static functions which do not behave static at all. |
| 02-19-2009, 08:09 PM | #6 | ||||
Quote:
It is possible to make it work with ForGroup and ForForce, the problem is that I can't think of a good use whatsoever for that, you'll often want to pass a bunch of stuff not just this, unlike timers in which it is more intuitive. Quote:
JASS:struct aaaa string msg method onTime takes nothing returns nothing call BJDebugMsg(I2S(GetTimerData(GetExpiredTimer())) + " -- " + this.msg) endmethod method test1 takes nothing returns nothing set this.msg="=????" call this.onTime.timeOut(1.00) endmethod static method test2 takes nothing returns nothing local aaaa A = aaaa.create() set A.msg="/ / / / /" call a.onTime.timeLoop(1.05) //The catch is , how to make the loop stop? endmethod endstruct Quote:
Quote:
|
| 02-19-2009, 10:55 PM | #7 |
Well, if it's for abstraction then NewTimer and ReleaseTimer should be automated completely. Maybe something like JASS:struct foo method bar takes nothing returns whatever endmethod static method create takes nothing returns foo local foo this = foo.allocate() call .bar.delayed(5.0) return this endmethod endstruct The only question is, could you do call .bar.delayed(5.0) from within the bar method, since that'd be a simple way to get it to loop? |
| 02-19-2009, 11:06 PM | #8 |
There is a .delayed keyword? |
| 02-19-2009, 11:15 PM | #9 |
No, I just made it up. |
| 02-19-2009, 11:44 PM | #10 |
I see. |
| 02-20-2009, 11:30 AM | #11 | |
Quote:
Maybe a new pseudo-native to stop the loop JASS:call stopTimeLoop() JASS:call PauseTimer(GetExpiredTimer()) call ReleaseTimer(GetExpiredTimer()) But often I use TT or something like that for periodic things, so maybe you should add an way to use methods with function interfaces so they could be used in systems like TT. |
