Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Flexible array problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Raknarg




PostPosted: 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) Razz
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: 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




PostPosted: Mon May 02, 2011 9:03 am   Post subject: RE:Flexible array problem

ok thanks
+1 karma
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: