[General] Quick Question!

Status
Not open for further replies.
Level 4
Joined
Jan 27, 2008
Messages
72
Hey guys, I'm wondering about a few things related to variables.

If you are using a player variable named Blue, and if there is a trigger that sets Blue = player 1 (red), then will this setting be destroyed if you later turn off this trigger?

If not, how do you destroy a player variable?

Thanks,
 
That is indeed true.

However, he is not destroying it. He is emptying it instead ^.^
A variable after all, is nothing more then a pointer reference towards a handle (object).

wikipedia said:
Objects allocated from the heap must be reclaimed—especially when the objects are no longer needed. In a garbage-collected language (such as C#, Java, and Lisp), the runtime environment automatically reclaims objects when extant variables can no longer refer to them. In non-garbage-collected languages, such as C, the program (and the programmer) must explicitly allocate memory, and then later free it, to reclaim its memory. Failure to do so leads to memory leaks, in which the heap is depleted as the program runs, risks eventual failure from exhausting available memory.

When a variable refers to a data structure created dynamically, some of its components may be only indirectly accessed through the variable. In such circumstances, garbage collectors (or analogous program features in languages that lack garbage collectors) must deal with a case where only a portion of the memory reachable from the variable needs to be reclaimed.
 
Indeed it will Arhowk, indeed it will :D

So he probably needs to make sure not to use it when it is referenced to null (nothing).
Most programming languages have protection for checking against a variable containing null.
Or even when using it in function calls. (Which eventually can lead to bottlenecks when debugging your code though).
A shame that Jass doesn't have this protection. I could think of some useful scenario's in this case :(
 
Status
Not open for further replies.
Back
Top