• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[VJASS] Shadowing functions

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,342
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).

JASS:
struct myStruct
static method create takes handle h returns thistype
...
endmethod
static method create takes integer unitTypeId returns thistype
...
endmethod
endstruct
 
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).
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.
 
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.

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.
 
Status
Not open for further replies.
Back
Top