HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Struct Methods

06-23-2009, 12:01 AM#1
Silvenon
Why does this work:

Collapse JASS:
struct Data
    timer t = CreateTimer()
    // ...
    static method create takes nothing returns Data
        local Data dat = Data.allocate()
        //...
        //...
        call TimerStart(dat.t, 0.035, true, function Data.Callback)
        return dat
    endmethod
    
    static method Callback takes nothing returns nothing
        call DoSomething()
    endmethod
endstruct

And this doesn't compile:

Collapse JASS:
struct Data
    timer t = CreateTimer()
    // ...
    static method create takes nothing returns Data
        local Data dat = Data.allocate()
        //...
        //...
        call TimerStart(dat.t, 0.035, true, function dat.Callback)
        return dat
    endmethod
    
    method Callback takes nothing returns nothing
        call DoSomething()
    endmethod
endstruct

?

I'm apparently still not clear with these things.. :(
06-23-2009, 01:50 AM#2
ToukoAozaki
While .NET delegates support non-static methods as they can link to instances, Jass2 callbacks don't. This means vJass is also not capable of them.

And yes, vJass is a just preprocessor; it becomes as Litany said.
06-23-2009, 02:51 AM#3
Silvenon
Thanks :D