Computer Science Canada Flexible Arrays in Procedures |
Author: | Silinter [ Sun May 25, 2008 1:30 pm ] | ||
Post subject: | Flexible Arrays in Procedures | ||
Alright, here is my problem, nice and short. I want a procedure to take in a flexible array and change it; i.e.
however, it gives me a syntax error. Does Turing support taking in flexible arrays in procedures? |
Author: | richcash [ Sun May 25, 2008 3:13 pm ] | ||
Post subject: | Re: Flexible Arrays in Procedures | ||
I don't believe so, but someone else may be able to confirm this as a fact. You may already know that you can pass a flexible array as an argument if the parameter is a static array with an unknown upper bounds, but then during the procedure it will be treated as a static array.
But again, I'm not sure of how to change bounds of an array during a procedure. You could accomplish this by creating your own array class. What is the situation you need this for? There may be an alternative. |
Author: | Silinter [ Sun May 25, 2008 11:07 pm ] |
Post subject: | Re: Flexible Arrays in Procedures |
I wanted to create a procedure to take out elements from a flexible array, so I just thought it'd be easier if I made it into a procedure. Now what's all this talk about "array class"? |
Author: | richcash [ Mon May 26, 2008 3:22 am ] | ||
Post subject: | Re: Flexible Arrays in Procedures | ||
Yeah, I don't think that can be done in turing. Unfortunately, you can't make a procedure to remove an element from an array. But, you can make a class that represents a flexible array and solve most if not all limitations associated with flexible arrays in turing. Like this, for example :
You can pass an Array object as a parameter to a function, and with more methods than in my poor example, get the full functionality of a flexible array. Notice that now you don't need to make a procedure that removes an element because you can just make a method that does it for you. |