What, exactly, is the cost of each additional Global variable in your source code? Is it only the space that one global would take up in regular RAM memory (or is it video memory/VRAM?)?
So let me make sure I understand this: An integer global costs the number of bytes it takes to represent a number between -2147483648 to +2147483647... which is... 4 bytes (as CreateBank doc says), and a 32-bit number. So somewhere in RAM or VRAM, for every Global integer declared, that is done at a cost of 4 bytes more when the program is running. Is that correct?
I try to make all variables that I can local, but often come to a point that I can't figure out how to do some algorithm without adding another global (I fully admit it's very possibly due to my own brain limits, not necessarily what is possible if I could think of a better algorithm!) but I am not sure what the downside or cost is each time I do that.
Instead of storing them in Type fields, would an array (always global when dimmed anyway) be faster? If not what are the trade-offs? Readability of code is definitely a plus (code is so much harder to read than it is to write!!).
These threads have good comments on this too:
http://www.blitzbasic.com/Community/posts.php?topic=33141#356613
http://www.blitzbasic.com/Community/posts.php?topic=76454#854999
Good to know that it does not tax the CPU during runtime as I read in one of those threads.
So let me make sure I understand this: An integer global costs the number of bytes it takes to represent a number between -2147483648 to +2147483647... which is... 4 bytes (as CreateBank doc says), and a 32-bit number. So somewhere in RAM or VRAM, for every Global integer declared, that is done at a cost of 4 bytes more when the program is running. Is that correct?
I try to make all variables that I can local, but often come to a point that I can't figure out how to do some algorithm without adding another global (I fully admit it's very possibly due to my own brain limits, not necessarily what is possible if I could think of a better algorithm!) but I am not sure what the downside or cost is each time I do that.
Instead of storing them in Type fields, would an array (always global when dimmed anyway) be faster? If not what are the trade-offs? Readability of code is definitely a plus (code is so much harder to read than it is to write!!).
These threads have good comments on this too:
http://www.blitzbasic.com/Community/posts.php?topic=33141#356613
http://www.blitzbasic.com/Community/posts.php?topic=76454#854999
Good to know that it does not tax the CPU during runtime as I read in one of those threads.