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

Username:   Password: 
 RegisterRegister   
 Changing upper bound of flexible array inside of a procedure
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jQwotos




PostPosted: Mon Mar 06, 2017 1:03 pm   Post subject: Changing upper bound of flexible array inside of a procedure

What is it you are trying to achieve?
Is it possible to change the upper bound of a flexible array inside of a procedure when it is passed as a variable argument?
In addition, is it possible to declare a flexible array inside of a record?
What is the problem you are having?
I can't change the upper bound of a flexible array inside of a procedure.
I know we can pass a flexible array into a procedure by doing this
code:

procedure example(var list: array 1 .. * of typeSec)
end example

But I want to do something like this
code:

procedure example(var list: array 1 .. * of typeSec)
     new list, 10
end example

Please specify what version of Turing you are using
OpenTuring V1.2.0 beta (Running in Wine on a Mac)
Sponsor
Sponsor
Sponsor
sponsor
pttptppt




PostPosted: Mon Mar 06, 2017 10:25 pm   Post subject: RE:Changing upper bound of flexible array inside of a procedure

I could be very wrong as Im a complete noob. But Im pretty sure the first example is not actually a flexible array.
From what Ive used in flexible arrays, the format is like:
var list: flexible array 1 .. 0 of typeSpec

and then
new list, 10

I have never done that by putting it in a procedure parameters like that but you could get around that very easily, though not as efficiently.

Perhaps if you share what your trying to accomplish, I can provide an alternative? Otherwise hope someone from this inactive forum site responds!
jQwotos




PostPosted: Mon Mar 06, 2017 10:29 pm   Post subject: RE:Changing upper bound of flexible array inside of a procedure

this would be my deceleration and procedure
code:

var list: flexible array 1 .. 9 of typeSec

procedure modify_array(var list: array 1 .. * of typeSec)
     new list, upper(list) + 1
     % do stuff
end modify_array

because turing doesn't like
code:

procedure modify_array(var list: flexible array 1 .. * of typeSec)
     new list, upper(list) + 1
     % do stuff
end modify_array

because it won't accept "flexible" when trying to pass it into the procedure
Insectoid




PostPosted: Thu Mar 09, 2017 12:38 pm   Post subject: RE:Changing upper bound of flexible array inside of a procedure

Turing is incomplete and flexible arrays are one of the features that was never completely implemented. I recommend avoiding them, and just using large fixed-length arrays instead.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: