[vJass?] Static / Dynamic

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Ignore Cohadar's link, it is totally unrelated to your question.

Your question is quite lame, it is mostly like "why not use a fork instead of using a knife"? You are kind of making a false dichotomy as if globals and structs were meant to solve the same problem, when they are meant to solve different problems.

globals: static , structs : dynamic. There is huge difference.

You could use a global array and some pointer like value and some pseudo allocation/deallocation but then, you would be doing exactly what structs do already.


In short, your post seems to come from a huge misunderstanding on what structs are. Please post some of your code in which you "replace structs with globals" .
As vexorian said in post. Globals are static while structs are dynamic.
I would like some explain of static and dynamic.

Don't, again tell me to read the manual. It has nothing to do with this.
 

N-a-z-g-u-l

New Member
Reaction score
30
static means, you set a specific variable to anything, which will be accessed from everywhere... so counting kills uses a static variable

dynamic means that variables are "created" for your use... in most cases array spaces are allocated and freed afterwards... so the variable content alwas changes, and its always used by different scripts... it would not make sense to access the variable with a specific index, as all indexes are dynamically created

afaik...^^
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>static means, you set a specific variable to anything, which will be accessed from everywhere... so counting kills uses a static variable

dynamic means that variables are "created" for your use... in most cases array spaces are allocated and freed afterwards... so the variable content alwas changes, and its always used by different scripts... it would not make sense to access the variable with a specific index, as all indexes are dynamically created

No idea what you talking about. @.@

>>static = single
dynamic = more instances (== MUI)

Single? Single what..?
 

Silvenon

New Member
Reaction score
19
No idea what you talking about. @.@

He meant that they are created each time it is used, that means a new instance is created. I look at it like locals, they don't interfere with other locals.

Single? Single what..?

Yeah, I'm missing a word here, I couldn't find the right term. I meant to say single instance, probably. That means you're always using the same one, you cannot make more instances of it (except arrays, maybe....).
 

N-a-z-g-u-l

New Member
Reaction score
30
JASS:
//dynamic:

local integer i = GetSomeFreeId()
set udg_Arr<i> = something
// do things with it, its a dynamically created &quot;variable&quot;
// the index i is always different and depends on how many instances you have already created
// no other function will use the same index with GetSomeFreeId(), until you destroy them properly
call FreeId(i)


//static:

set udg_Arr[100] = something
// this id will evereytime be 100, its static, wont change <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
</i>



perhaps this helped^^

GetSomeFreeId() is just a function which allocates an array index dynamically, it does not exist in reality, some for FreeId()... this is how most dynamical systems work


EDIT: everything which has to be created and destroyed is dynamic... static are those things which wont be destroyed or created
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> dynamic is MUI, static is faster and can be read from everywhere


???
Um... what?

People, please, Gals is already confused enough about something that even a basic dictionary lookup could clear once and for all.
Don't come with..., ..., with... "theories"?
 

N-a-z-g-u-l

New Member
Reaction score
30
removed it from my post :)

i just wanted to offer different ways how you can explain it, i hope the example is enough^^

and normally, if you dont know what static or dynamic is, you dont even need to know it ;) you will see on your own whats better in your case, when you compare the systems themselves...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top