HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

vJass Compiler question

06-16-2008, 08:57 PM#1
Feroc1ty
Would it be possible to implement function overloading into vJass?
06-17-2008, 12:42 PM#2
Themerion
Do you mean like this?
Collapse JASS:
interface Data
    method doSomething takes nothing returns nothing defaults nothing
endinterface

struct DataEx extends Data
    unit u
    method doSomething takes nothing returns nothing
        call BJDebugMsg(GetUnitName(u))
    endmethod
endstruct

function Actions takes nothing returns nothing
    local Data d=DataEx.create()
    call d.doSomething()
endfunction
06-17-2008, 12:56 PM#3
PitzerMike
It's certainly possible using name mangling like in c++ for example.
Do we want overloading?

PS: No Themerion, overloading means two (or more) functions with the same name but different parameters. Depending on the type and number of passed in arguments the compiler can decide which is to be used.
06-17-2008, 01:02 PM#4
TheDamien
Hopefully not before there is more powerful operator overloading and proper virtual methods.
06-17-2008, 01:47 PM#5
PandaMine
Overloading is aweasome for systems, my AMHS would benefit from it.

All we have now is operator overloading
06-17-2008, 02:47 PM#6
Vexorian
Planned stuff:
- "extends struct" : A super keyword that allows you to use the paren'ts interface-replacing methods.
- "interfaces,extends stuff": parent's create will have the correct type if called from a child (so you can call the child's interface methods from there)
- function 'overloading' will not be implemented, but I think I will allow default arguments.