Talk:Plan for real script arrays
I'd be content to be able to do the following:
global variable(1, myArray) myArray[5] := 3
instead of the following:
declare constant(1, myArray) write global(myArray+5, 3)
And it'd be way easy to implement, too. --Moogle1 21:29, 17 September 2008 (UTC)
Bob the Hamster: The problem with that is you are still accessing global variables in a way that requires fixed numeric offsets. That makes it a pain in the slime to re-size arrays, and means no error checking for out-of-bounds array access. The proposal I have outlined here will actually be very easy to implement except for the syntax magic in hspeak-- so a hack with global variables would not be any easier because it would still require the same syntax magic in hspeak.
Moogle1 oh :( Well, that said, where are the arrays coming from? Are they part of the global variable heap? And is there any possibility of magic shortcuts for readglobal/writeglobal? (I am thinking here of a magical "global" array, like "global[35] = 2" or something)
Bob the Hamster: The arrays would be totally separate memory space. They would be global, just like global variables, except that they wouldn't be saved in .SAV files until sometime after we get around to implementing a new save format. As for a magic shortcut for readglobal and writeglobal, I am not sure. Maybe. I haven't worked with the hspeak source in a while, and I'm afraid I can't remember how the current magic works, so I couldns't say yet which kinds of magic we could add in the future.