Author |
Message |
Tyr_God_Of_War
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Vermette
![](http://compsci.ca/v3/uploads/user_avatars/637825944810b5d4444c6.jpg)
|
Posted: 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? |
|
|
|
|
![](images/spacer.gif) |
Tyr_God_Of_War
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: 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++. |
|
|
|
|
![](images/spacer.gif) |
drij
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Tyr_God_Of_War
|
Posted: Sat Dec 13, 2008 9:57 pm Post subject: RE:Optional Procedure and Function parameters |
|
|
Well, thanks anyway. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|