HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Is this supposed to be valid vJass?

08-08-2009, 11:12 PM#1
dismas
Collapse JASS:
function duration takes nothing returns real
    return 3.0
endfunction

function bar takes nothing returns nothing
    call BJDebugMsg(R2S(duration)) // as opposed to duration()
endfunction

Plain WE gives me a syntax error but JassHelper compiles it. Btw I got "1.0" when I ran it after compiling in NewGen.
08-08-2009, 11:56 PM#2
moyack
Jasshelper catches vJASS errors and this one is a JASS error, so PJASS is doing it properly.

This must be the right way:

Collapse JASS:
function duration takes nothing returns real
    return 3.0
endfunction

function bar takes nothing returns nothing
    call BJDebugMsg(R2S(duration()))
endfunction

BTW, probably jasshelper is taking that function as a object, when you call it in this way, you are getting the index of the function but not the result.

Try this:

Collapse JASS:
function duration takes nothing returns real
    return 3.0
endfunction

function bar takes nothing returns nothing
    call BJDebugMsg(R2S(duration.execute()))
endfunction
08-09-2009, 12:46 AM#3
Vexorian
It is not supposed to be valid vJass. But jasshelper is very dumb, and it doesn't do type safety.

So it thinks Duration was an attempt to use a function pointer, it translates it to some integer number, and then PJass compiles it as correct.