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

Username:   Password: 
 RegisterRegister   
 Optional Parameters for my Procedure?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Cervantes




PostPosted: Fri Feb 11, 2005 6:24 pm   Post subject: Optional Parameters for my Procedure?

Does anyone know if I can make my procedure have optional parameters? That is to say, if it were in the Turing Reference, it would look something like this:
code:

procedure procName (paramater1 [, optionalParameter])


So, if I don't pass anything into optionalParameter when I call my procedure, the procedure will use a default value for that optionalParameter.
Any way to do this?
-Cervantes
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Fri Feb 11, 2005 8:18 pm   Post subject: (No subject)

AFAIK, OOT is too stupid to figure something out like that. I've seen the likes in Java and such...but I'm practically positive that it's not possible...or at least mightily difficult.
Methinks it would mean declaring several procs, all under the same name, each w/ different paramters. This, of course, is not do-able in OOT. The closest you could get to this would be to have a standard number of procs, each w/ a on/off signal. I'll think about it a bit more, see if I can figure something else out...could be useful if possible.
Cervantes




PostPosted: Fri Feb 11, 2005 9:26 pm   Post subject: (No subject)

Don't hurt yourself working too much on this. It'd be very interesting to see if it could be done and how, but, at least for my current project, it's not all that necessary.
Thanks Delos,
-Cervantes
Delos




PostPosted: Fri Feb 11, 2005 10:48 pm   Post subject: (No subject)

Idea:

Ok, this is most definitely not efficient...but meh, it's as much as I can come up w/ whilest dealing w/ the constraints of OOT.

Make a proc. For the parameter, use an array whose upper bound is not defined (dynamic array?). I.e. "var arr : array 1 .. * of string" sorta deal.
The array itself that will be called in the proc will be a flexible array.
Each element will contain some sort of ID, be it an int, command-word-type-string, boolean, or whatever.
A loop within the main proc will take each element in turn, and associate its ID to a particular fcn. These may be predefined routines, or things within the main proc...if you want a long proc of course Wink.
Since the array is flexible, you can have as many or as few commands sent to the proc as you want.
Case structures will probably be your friend, since iffing it out will be quite-some tedious.
I can see that it probably defeats the purpose if you have to define a dozen other mini-procs to go along w/ the case...but as I said earlier...limitations...[sigh]

On a much happier note, I just finished my Bio midterm. I'm quite ecstatic about that. The bio department here has a fondness for screwing us over as much as possible, as often as possible...oh, and look at me looking to major in the bloody subject (double major, w/ Psych). Yes, I am an idiot. Or at least a sucker for punishment. Probably both.

Right, off to do something productive now, like sleep.
AsianSensation




PostPosted: Fri Feb 11, 2005 11:25 pm   Post subject: Re: Optional Parameters for my Procedure?

Cervantes wrote:
Does anyone know if I can make my procedure have optional parameters? That is to say, if it were in the Turing Reference, it would look something like this:
code:

procedure procName (paramater1 [, optionalParameter])


So, if I don't pass anything into optionalParameter when I call my procedure, the procedure will use a default value for that optionalParameter.
Any way to do this?
-Cervantes


That looks like function overloading, and the answer is a big NO.

Sometimes I want to smack Turing, this is one of the times.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: