| 04-04-2007, 08:04 PM | #1 |
Excuse my ignorance, but I was just wondering: In any other language I've tried to learn you need to declare the size of an array. Why is this not so in JASS(2)? And what affect does this have on memory usage? |
| 04-04-2007, 08:13 PM | #2 |
I'm just guessing, but I think it just automatically sets the size to the max amount (8192) and you can fill in those slots. It seems logical, but don't take my word for it unless I'm correct. |
| 04-04-2007, 08:18 PM | #3 |
It automatically sets the size to 8192. But there's a trap, if you use the 8192th index (8191) the map will crash when you load a saved game of the map. So the actualy array size is 8191 And yes, it sucks, and it sucks a lot . |
| 04-04-2007, 08:31 PM | #4 | |
Quote:
So basically if I only want an array of say 5, It's just wasting a bunch of space? |
| 04-04-2007, 08:40 PM | #5 |
I don't think it actually wastes it persey. Maybe it does, but I'd doubt it. |
| 04-04-2007, 09:06 PM | #7 |
Apparently the memory for jass arrays appears to be dynamically allocated to the largest index used, but your max size is always 8191. |
| 04-04-2007, 09:36 PM | #8 | |
Quote:
this is like c++ array[8192] means there are 8192 array elements, but the index starts from 0, so maximum index is 8191. And scripts arents same as programming, so mostly they are dynamic to keep things simple for their purpose |
| 04-04-2007, 09:46 PM | #9 |
No, you are wrong. Maximum index is 8191, but if you use it the map crashes when you load a saved game of it. So in fact max index is 8190 which means array size is 8191 |
| 04-05-2007, 12:36 AM | #10 |
oh i understand u now hmm. Thx for correction. weird problem to |
