Flexible array problem
Author |
Message |
Raknarg
|
Posted: Sun May 01, 2011 7:46 pm Post subject: Flexible array problem |
|
|
So is it possible to set the upper limit of a flexible array to a pointer value and just change that to change the value? If so, is there an easier way? (don't quite understand pointers) |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Sun May 01, 2011 8:05 pm Post subject: RE:Flexible array problem |
|
|
I don't think so. Turing appears to use a very basic array (just a special pointer + a size). This means when you create an array, Turing allocates a block of memory exactly large enough to contain that array. You cannot just increase the size because something else might have taken up the next few blocks of RAM.
A flexible array isn't flexible at all. If you 'resize' an array, Turing just creates a new array, and copies all elements of the old array into the new one (and then deletes the old one).
If you COULD assign the upper limit to a pointer, changing the pointer and trying to access the 'new cells' would likely return an array index out of bounds error. |
|
|
|
|
|
Raknarg
|
Posted: Mon May 02, 2011 9:03 am Post subject: RE:Flexible array problem |
|
|
ok thanks
+1 karma |
|
|
|
|
|
|
|