• 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.

some general questions about vJass

Status
Not open for further replies.
Level 7
Joined
Jan 30, 2011
Messages
267
1.) what are scopes? whats the difference between scopes and libraries and are there more "things" like these?
2.) what are modules? whats the difference between modules and structs and are there more "things" like these?
3.) what are textmacros?

thx in advance ;)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
1.) Libraries can require other libraries, which makes the compiler sort the code accordingly. Because in wc3, directly calling functions lower than the execution line is not possible.

Scopes are nestable.

Structs are also a kind of encapsulated, organized code.

I practically only use structs. They also offer to call functions below by internally creating a copy of the function at the top. However, if this top function needs to call below again, it will transform into the execution/evaluation of preset triggers. Simply said, it is not as performant for the game if you do not pay attention to that. Libraries are commonly used to share code with other people and to indicate which packs of code they require.

I am currently writing a tool that remakes the function-sorting/trigger evaluation process of struct methods/plain jass. Then, the only thing that nags me is that structs are not directly nestable.

2.) Modules are textmacros designed for structs. You can implement them into different ones and they practically paste their lines. They may have some sort of an own encapsulation though. You can make an onInit method private and it won't get into conflict with another onInit method in the struct or private onInit methods of other implemented modules.

3.) Textmacros write/copy lines of code for you from a //! textmacro-block you have declared before. They are pretty weak though but at least, in contrast to modules, you can pass static parameters that can substitute placeholders in your template. Their disadvantage to modules is that they are not nestable.
 
Status
Not open for further replies.
Top