1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[VJASS] Shadowing functions

Discussion in 'Warcraft Editing Tools' started by sethmachine, Jan 5, 2014.

  1. sethmachine

    sethmachine

    Joined:
    Aug 7, 2013
    Messages:
    1,318
    Resources:
    0
    Resources:
    0
    Hi,

    Just curious if we could shadow methods in VJASS. What I mean is, is that it appears you have multiple functions/methods with the same name, but the parameters they take are different (hence they are distinguishable). The code they run obviously can be anything (doesn't have to be the same).

    For example, it would be nice to shadow create methods (at least for what I'm doing).

    Code (vJASS):

    struct myStruct
    static method create takes handle h returns thistype
    ...
    endmethod
    static method create takes integer unitTypeId returns thistype
    ...
    endmethod
    endstruct
     
     
  2. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,430
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
  3. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,199
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    It is called overloading not shadowing.

    JASS as a language does not allow for it. It is also only eye candy for ease of programming since nothing stops you calling the functions the same name with a suffix at the end.
     
  4. sethmachine

    sethmachine

    Joined:
    Aug 7, 2013
    Messages:
    1,318
    Resources:
    0
    Resources:
    0
    Yes of course couldn't remember the term for it thanks.

    Well it'd be trivial to put into VJASS like you said, you'd just check the parameters and you'd know which function to replace it, e.g. "create_1" or "create_2." Still think it'd be useful to add in.