• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[VJASS] Shadowing functions

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

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
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.
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
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.
Top