I'm sorry could you private message me a better description as to what happens in KaTTaNa's big long Handle Locals crap. I know how to use it very slightly and you seem to know what your talking about. The only way I know hwo to use it properly is when using a timer. such as SetHandleHandle(timer,"name",value), also why do u need SetHandleREAL but not SetHandleUNIT...?
H2I
not ratedThe quintessiential H2I, the crux that all return bugging code uses. This function was made popular by a bunch of people and me. The function is used to store a handle's address in an integer.
How this work:
All variable types in warcraft 3 are four bytes in length. The atomic types (ints, reals, and booleans) use thier four bytes as direct value. Handles use thier four bytes of space as a "pointer" to thier object they references "memory address". I use the terms "pointer" loosely. As they are not first class pointers. As well as "memory address", it is believed all objects are stored in a specific heap and these are thier keys to them. But that is irrelavant.
Anyway, the Jass parser only checks the last return value satiates the return type. Thus we "trick" it into taking a handle when it really was meant to take an integer.
In a similar fashion you can write your own function to typecast from integer to handle. Or to a specific handle. Note: that if you'd like to convert a handle to another type you only need to something like this
[code]
function H2U takes handle h returns unit
return h
endfunction
[/code]
As the return type checker only makes sure that the type being returned is a handle, if it checking for a child of handle.
Not all the non-atomic types are handles though. There are two other types of data. There is the [u]code[/u] type. It is what is used to store an address to a function. There isalso the [u]string[/u]. Jass has a redudancy check to make sure that all strings which have the same literal content are stored under the same address. Jass was made with poor coders in mind. Having to keep track of all usage of strings would have been maddening as there is no real time garbage collector.
[b]Okay fine, you explained it but why now? Why submit H2I now, when there are a million and four snippets of code that use it?[/b]
Because, I think its time to no longer be that blacksheep function that most new jass scripters find as some evil deviance. When its fully explained how it works, and such people might not have thier irrational fear. What wasn't mention in the question was how thier are also about a thousand variations of a function to convert handles to integers. I think its already been determined that this is the most popular variant, and hopefully the willing will be inclined to modify thier old projects and that this shall become the gold standard for type casting handles to ints.
...Now if only we can figure out some resolve on how people use Gamecache!
How this work:
All variable types in warcraft 3 are four bytes in length. The atomic types (ints, reals, and booleans) use thier four bytes as direct value. Handles use thier four bytes of space as a "pointer" to thier object they references "memory address". I use the terms "pointer" loosely. As they are not first class pointers. As well as "memory address", it is believed all objects are stored in a specific heap and these are thier keys to them. But that is irrelavant.
Anyway, the Jass parser only checks the last return value satiates the return type. Thus we "trick" it into taking a handle when it really was meant to take an integer.
In a similar fashion you can write your own function to typecast from integer to handle. Or to a specific handle. Note: that if you'd like to convert a handle to another type you only need to something like this
[code]
function H2U takes handle h returns unit
return h
endfunction
[/code]
As the return type checker only makes sure that the type being returned is a handle, if it checking for a child of handle.
Not all the non-atomic types are handles though. There are two other types of data. There is the [u]code[/u] type. It is what is used to store an address to a function. There isalso the [u]string[/u]. Jass has a redudancy check to make sure that all strings which have the same literal content are stored under the same address. Jass was made with poor coders in mind. Having to keep track of all usage of strings would have been maddening as there is no real time garbage collector.
[b]Okay fine, you explained it but why now? Why submit H2I now, when there are a million and four snippets of code that use it?[/b]
Because, I think its time to no longer be that blacksheep function that most new jass scripters find as some evil deviance. When its fully explained how it works, and such people might not have thier irrational fear. What wasn't mention in the question was how thier are also about a thousand variations of a function to convert handles to integers. I think its already been determined that this is the most popular variant, and hopefully the willing will be inclined to modify thier old projects and that this shall become the gold standard for type casting handles to ints.
...Now if only we can figure out some resolve on how people use Gamecache!