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

Username:   Password: 
 RegisterRegister   
 Optional Procedure and Function parameters
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tyr_God_Of_War




PostPosted: Tue Dec 09, 2008 9:44 pm   Post subject: Optional Procedure and Function parameters

Can you create optional parameters?

example:

intstr ( i : int [ , width : int [ , base : int ] ] ) : string

The width and base parameters are optional.
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Dec 09, 2008 9:48 pm   Post subject: RE:Optional Procedure and Function parameters

umm..not in my knowledge. In languages like Perl it is definitely possible, though nothing is really to be gained by it. Why would you want to?
Tony




PostPosted: Tue Dec 09, 2008 9:51 pm   Post subject: RE:Optional Procedure and Function parameters

because sometimes you might want to specify one of many arguments to be some value other than a default one.

Turing might have a way (or a workaround to the same effect), but I'm not sure.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Vermette




PostPosted: Tue Dec 09, 2008 9:56 pm   Post subject: Re: Optional Procedure and Function parameters

Just some clarification; are you referring to Overloading, or Variadics?
Tyr_God_Of_War




PostPosted: Wed Dec 10, 2008 12:00 am   Post subject: RE:Optional Procedure and Function parameters

I wanted to do something just like the intstr or strint functions; where if you omit parameters a default value is used instead.

I would gladly use either one if possible in Turing. Variadics would be easier to do what I had in mind, however.
[Gandalf]




PostPosted: Wed Dec 10, 2008 2:02 am   Post subject: RE:Optional Procedure and Function parameters

Sadly, Turing offers neither. Though I suppose you can override procedures in inherited classes, but that's not really what you're looking for.

intstr() and others work as they do because they are programmed into the Turing environment/compiler/interpreter in C or C++.
drij




PostPosted: Fri Dec 12, 2008 2:41 pm   Post subject: Re: Optional Procedure and Function parameters

Workaround:
code:
procedure full (param_1, param_2, param_3)
     /* Code Here */
end full

procedure shorter (param_1, param_2)
     full (param_1, param_2, {param_3 Default Value})
end shorter

procedure shortest (param_1)
     shorter (param_1, {param_2 Default Value})
end shortest


It's not really what you asked for, but it's about the closest you can come in Turing.
Tyr_God_Of_War




PostPosted: Sat Dec 13, 2008 9:57 pm   Post subject: RE:Optional Procedure and Function parameters

Well, thanks anyway.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: